Make ASWeakMapEntry Value Atomic (#555)

* Make ASWeakMapEntry value atomic

* Increment changelog

* Go a little nuts

* Update CHANGELOG.md
This commit is contained in:
Adlai Holler
2017-09-08 07:17:35 -07:00
committed by Huy Nguyen
parent 0bd18c8522
commit 53e99cc762
3 changed files with 9 additions and 12 deletions

View File

@@ -17,6 +17,7 @@
- [ASEditableTextNode] added -editableTextNodeShouldBeginEditing to ASEditableTextNodeDelegate to mirror the corresponding method from UITextViewDelegate. [Yan S.](https://github.com/yans) [#535](https://github.com/TextureGroup/Texture/pull/535)
- [Breaking] Remove APIs that have been deprecated since 2.0 and/or for at least 6 months [Huy Nguyen](https://github.com/nguyenhuy) [#529](https://github.com/TextureGroup/Texture/pull/529)
- [ASDisplayNode] Ensure `-displayWillStartAsynchronously:` and `-displayDidFinish` are invoked on rasterized subnodes. [Eric Scheers](https://github.com/smeis) [#532](https://github.com/TextureGroup/Texture/pull/532)
- Fixed a memory corruption issue in the ASImageNode display system. [Adlai Holler](https://github.com/Adlai-Holler) [#555](https://github.com/TextureGroup/Texture/pull/555)
##2.4
- Fix an issue where inserting/deleting sections could lead to inconsistent supplementary element behavior. [Adlai Holler](https://github.com/Adlai-Holler)

View File

@@ -28,7 +28,7 @@ NS_ASSUME_NONNULL_BEGIN
AS_SUBCLASSING_RESTRICTED
@interface ASWeakMapEntry<Value> : NSObject
@property (nonatomic, retain, readonly) Value value;
@property (atomic, strong, readonly) Value value;
@end
@@ -49,7 +49,7 @@ AS_SUBCLASSING_RESTRICTED
* The underlying storage is a hash table and the Key type should implement `hash` and `isEqual:`.
*/
AS_SUBCLASSING_RESTRICTED
@interface ASWeakMap<__covariant Key : NSObject *, Value> : NSObject
@interface ASWeakMap<__covariant Key, Value> : NSObject
/**
* Read from the cache. The Value object is accessible from the returned ASWeakMapEntry.

View File

@@ -18,12 +18,13 @@
#import <AsyncDisplayKit/ASWeakMap.h>
@interface ASWeakMapEntry ()
@property (nonatomic, strong) NSObject *key;
@property (nonatomic, strong, readonly) id key;
@property (atomic, strong) id value;
@end
@implementation ASWeakMapEntry
- (instancetype)initWithKey:(NSObject *)key value:(NSObject *)value
- (instancetype)initWithKey:(id)key value:(id)value
{
self = [super init];
if (self) {
@@ -33,16 +34,11 @@
return self;
}
- (void)setValue:(NSObject *)value
{
_value = value;
}
@end
@interface ASWeakMap ()
@property (nonatomic, strong) NSMapTable<NSObject *, ASWeakMapEntry *> *hashTable;
@property (nonatomic, strong, readonly) NSMapTable<id, ASWeakMapEntry *> *hashTable;
@end
/**
@@ -69,12 +65,12 @@
return self;
}
- (ASWeakMapEntry *)entryForKey:(NSObject *)key
- (ASWeakMapEntry *)entryForKey:(id)key
{
return [self.hashTable objectForKey:key];
}
- (ASWeakMapEntry *)setObject:(NSObject *)value forKey:(NSObject *)key
- (ASWeakMapEntry *)setObject:(id)value forKey:(id)key
{
ASWeakMapEntry *entry = [self.hashTable objectForKey:key];
if (entry != nil) {