YYThreadSafeDictionary.h 939 B

123456789101112131415161718192021222324252627282930
  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. A simple implementation of thread safe mutable dictionary.
  14. @discussion Generally, access performance is lower than NSMutableDictionary,
  15. but higher than using @synchronized, NSLock, or pthread_mutex_t.
  16. @discussion It's also compatible with the custom methods in `NSDictionary(YYAdd)`
  17. and `NSMutableDictionary(YYAdd)`
  18. @warning Fast enumerate(for...in) and enumerator is not thread safe,
  19. use enumerate using block instead. When enumerate or sort with block/callback,
  20. do *NOT* send message to the dictionary inside the block/callback.
  21. */
  22. @interface YYThreadSafeDictionary : NSMutableDictionary
  23. @end