[ASDisplayNode+AsyncDisplay] Add locking for _flags (although write-once-on-init, this quiets the Thread Sanitizer).

This commit is contained in:
Scott Goodson
2016-07-09 23:50:40 -07:00
parent 3efd01a781
commit 1d07759c9e

View File

@@ -182,7 +182,11 @@ static void __ASDisplayLayerDecrementConcurrentDisplayCount(BOOL displayIsAsync,
- (asyncdisplaykit_async_transaction_operation_block_t)_displayBlockWithAsynchronous:(BOOL)asynchronous isCancelledBlock:(asdisplaynode_iscancelled_block_t)isCancelledBlock rasterizing:(BOOL)rasterizing
{
asyncdisplaykit_async_transaction_operation_block_t displayBlock = nil;
ASDisplayNodeFlags flags;
_propertyLock.lock();
flags = _flags;
_propertyLock.unlock();
ASDisplayNodeAssert(rasterizing || !(_hierarchyState & ASHierarchyStateRasterized), @"Rasterized descendants should never display unless being drawn into the rasterized container.");
if (!rasterizing && self.shouldRasterizeDescendants) {
@@ -226,7 +230,7 @@ static void __ASDisplayLayerDecrementConcurrentDisplayCount(BOOL displayIsAsync,
return image;
};
} else if (_flags.implementsInstanceImageDisplay || _flags.implementsImageDisplay) {
} else if (flags.implementsInstanceImageDisplay || flags.implementsImageDisplay) {
// Capture drawParameters from delegate on main thread
id drawParameters = [self drawParameters];
@@ -242,7 +246,7 @@ static void __ASDisplayLayerDecrementConcurrentDisplayCount(BOOL displayIsAsync,
UIImage *result = nil;
//We can't call _willDisplayNodeContentWithRenderingContext or _didDisplayNodeContentWithRenderingContext because we don't
//have a context. We rely on implementors of displayWithParameters:isCancelled: to call
if (_flags.implementsInstanceImageDisplay) {
if (flags.implementsInstanceImageDisplay) {
result = [self displayWithParameters:drawParameters isCancelled:isCancelledBlock];
} else {
result = [[self class] displayWithParameters:drawParameters isCancelled:isCancelledBlock];
@@ -251,7 +255,7 @@ static void __ASDisplayLayerDecrementConcurrentDisplayCount(BOOL displayIsAsync,
return result;
};
} else if (_flags.implementsInstanceDrawRect || _flags.implementsDrawRect) {
} else if (flags.implementsInstanceDrawRect || flags.implementsDrawRect) {
CGRect bounds = self.bounds;
if (CGRectIsEmpty(bounds)) {
@@ -281,7 +285,7 @@ static void __ASDisplayLayerDecrementConcurrentDisplayCount(BOOL displayIsAsync,
_willDisplayNodeContentWithRenderingContext(currentContext);
}
if (_flags.implementsInstanceDrawRect) {
if (flags.implementsInstanceDrawRect) {
[self drawRect:bounds withParameters:drawParameters isCancelled:isCancelledBlock isRasterizing:rasterizing];
} else {
[[self class] drawRect:bounds withParameters:drawParameters isCancelled:isCancelledBlock isRasterizing:rasterizing];