Re: am I being called on the correct GCD queue?
Re: am I being called on the correct GCD queue?
- Subject: Re: am I being called on the correct GCD queue?
- From: Gwynne Raskind <email@hidden>
- Date: Sat, 09 Feb 2013 19:43:32 -0500
The replacement I've seen for checking whether the current queue is "correct" for the code in which it's running looks something like this (for a complete implementation example, see GCDAsyncSocket):
static char *kMYObjectIsOnItsOwnQueueKey = "Whatever":
- (instancetype)init
{
if ((self = [super init])) {
// ...
_myQueue = dispatch_queue_create(...);
dispatch_queue_set_specific(_myQueue, kMYObjectIsOnItsOwnQueueKey, (__bridge void *)self, NULL);
}
return self;
}
- (BOOL)isExecutingOnMyQueue
{
return dispatch_get_specific(kMYObjectIsOnItsOwnQueueKey) == (__bridge void *)self;
}
-- Gwynne Raskind
On Feb 9, 2013, at 7:19 PM, Kyle Sluder <email@hidden> wrote:
> On Feb 9, 2013, at 12:11 PM, Matt Neuburg <email@hidden> wrote:
>
>> If dispatch_get_current_queue() is deprecated
>
> It's not deprecated in any currently non-NDA'd SDK.
>
>
>> how can I check whether this method is being called on the right dispatch queue? For example, I'd like to throw a wobbly (an assertion, maybe) if this method is called on any queue whose label isn't "com.neuburg.myCoolQueue". Is that a wrong thing to want to do? Thx - m.
>
> Maybe dispatch_queue_specific can be used here?
>
> --Kyle Sluder
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden