YYThreadSafeDictionary.h 992 B

123456789101112131415161718192021222324252627282930313233
  1. //
  2. // YYThreadSafeDictionary.h
  3. // YYKit <https://github.com/ibireme/YYKit>
  4. //
  5. // Created by ibireme on 14/10/21.
  6. // Copyright (c) 2015 ibireme.
  7. //
  8. // This source code is licensed under the MIT-style license found in the
  9. // LICENSE file in the root directory of this source tree.
  10. //
  11. #import <Foundation/Foundation.h>
  12. /**
  13. @warning OSSpinLock is not safe anymore...
  14. */
  15. /**
  16. A simple implementation of thread safe mutable dictionary.
  17. @discussion Generally, access performance is lower than NSMutableDictionary,
  18. but higher than using @synchronized, NSLock, or pthread_mutex_t.
  19. @discussion It's also compatible with the custom methods in `NSDictionary(YYAdd)`
  20. and `NSMutableDictionary(YYAdd)`
  21. @warning Fast enumerate(for...in) and enumerator is not thread safe,
  22. use enumerate using block instead. When enumerate or sort with block/callback,
  23. do *NOT* send message to the dictionary inside the block/callback.
  24. */
  25. @interface YYThreadSafeDictionary : NSMutableDictionary
  26. @end