YYThreadSafeArray.h 899 B

123456789101112131415161718192021222324252627282930
  1. //
  2. // YYThreadSafeArray.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 array.
  14. @discussion Generally, access performance is lower than NSMutableArray,
  15. but higher than using @synchronized, NSLock, or pthread_mutex_t.
  16. @discussion It's also compatible with the custom methods in `NSArray(YYAdd)`
  17. and `NSMutableArray(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 array inside the block/callback.
  21. */
  22. @interface YYThreadSafeArray : NSMutableArray
  23. @end