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 protected]> wrote:
> On Feb 9, 2013, at 12:11 PM, Matt Neuburg <[email protected]> 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 protected])
>
> 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:
> https://lists.apple.com/mailman/options/cocoa-dev/gwynne%40darkrainfall.org
>
> This email sent to [email protected]
_______________________________________________
Cocoa-dev mailing list ([email protected])
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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]