RecursiveLock.swift 719 B

12345678910111213141516171819202122232425262728293031323334
  1. //
  2. // RecursiveLock.swift
  3. // Platform
  4. //
  5. // Created by Krunoslav Zaher on 12/18/16.
  6. // Copyright © 2016 Krunoslav Zaher. All rights reserved.
  7. //
  8. import class Foundation.NSRecursiveLock
  9. #if TRACE_RESOURCES
  10. class RecursiveLock: NSRecursiveLock {
  11. override init() {
  12. _ = Resources.incrementTotal()
  13. super.init()
  14. }
  15. override func lock() {
  16. super.lock()
  17. _ = Resources.incrementTotal()
  18. }
  19. override func unlock() {
  20. super.unlock()
  21. _ = Resources.decrementTotal()
  22. }
  23. deinit {
  24. _ = Resources.decrementTotal()
  25. }
  26. }
  27. #else
  28. typealias RecursiveLock = NSRecursiveLock
  29. #endif