Fix race in ASDisplayNodeRespectThreadAffinityOfNode

This commit is contained in:
Shannon Ma 2015-08-10 16:42:02 -07:00
parent 6275219f79
commit c26e9c7e94

View File

@ -71,6 +71,9 @@ void ASDisplayNodeRespectThreadAffinityOfNode(ASDisplayNode *node, void (^block)
return;
}
{
// Hold the lock to avoid a race where the node gets loaded while the block is in-flight.
ASDN::MutexLocker l(node->_propertyLock);
if (node.nodeLoaded) {
ASDisplayNodePerformBlockOnMainThread(^{
block();
@ -79,6 +82,7 @@ void ASDisplayNodeRespectThreadAffinityOfNode(ASDisplayNode *node, void (^block)
block();
}
}
}
+ (void)initialize
{