Permalink
Browse files

Fixing potential concurrency issue with creating the actionQueue

  • Loading branch information...
1 parent 343b027 commit 52139bd8adeb3ae0e0d4012472b1cb996d119096 @blackgold9 blackgold9 committed Oct 10, 2012
Showing with 4 additions and 3 deletions.
  1. +4 −3 MagicalRecord/Core/MagicalRecord+Actions.m
@@ -13,10 +13,11 @@
dispatch_queue_t action_queue(void);
dispatch_queue_t action_queue(void)
{
- if (background_action_queue == NULL)
- {
+ static dispatch_once_t onceToken;
+ dispatch_once(&onceToken, ^{
background_action_queue = dispatch_queue_create("com.magicalpanda.magicalrecord.actionQueue", DISPATCH_QUEUE_SERIAL);
- }
+ });
+
return background_action_queue;
}

0 comments on commit 52139bd

Please sign in to comment.