You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
719 B

5 years ago
  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