Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## master
* Add your own contributions to the next release on the line below this with your name.
- [ASTextNode] Fix an race condition on ASTextKitAttributes [Heberti Almeida](http://github.com/hebertialmeida) [#819]
- [ASDisplayNode] Add unit tests for layout z-order changes (with an open issue to fix).
- [ASDisplayNode] Consolidate main thread initialization and allow apps to invoke it manually instead of +load.
- [ASRunloopQueue] Introduce new runloop queue(ASCATransactionQueue) to coalesce Interface state update calls for view controller transitions.
Expand Down
17 changes: 15 additions & 2 deletions Source/ASTextNode.mm
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,23 @@ - (BOOL)isEqual:(ASTextNodeRendererKey *)object
key.attributes = attributes;
key.constrainedSize = constrainedSize;

ASTextKitRenderer *renderer = [cache objectForKey:key];
static dispatch_queue_t rendererQueue;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
rendererQueue = dispatch_queue_create("org.AsyncDisplayKit.ASTextNode.renderer", DISPATCH_QUEUE_CONCURRENT);
dispatch_set_target_queue(rendererQueue, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0));
});

__block ASTextKitRenderer *renderer;
dispatch_sync(rendererQueue, ^{
renderer = [cache objectForKey:key];
});

if (renderer == nil) {
renderer = [[ASTextKitRenderer alloc] initWithTextKitAttributes:attributes constrainedSize:constrainedSize];
[cache setObject:renderer forKey:key];
dispatch_barrier_async(rendererQueue, ^{
[cache setObject:renderer forKey:key];
});
}

return renderer;
Expand Down