Re: How to cancel an asynchronous GCD block?
Re: How to cancel an asynchronous GCD block?
- Subject: Re: How to cancel an asynchronous GCD block?
- From: Oleg Krupnov <email@hidden>
- Date: Fri, 01 Jul 2011 11:51:00 +0300
>> I am migrating my code to use GCD blocks instead of NSOperations.
>
> Why?
I should have said, I'm writing a new app and I am migrating my
knowledge of implementing multi-threading from NSOperation to GCD :)
(And I should say, I'm beginning to like the easiness of GCD, even
though I was initially reluctant to use blocks, because they seem
harder to read, less encapsulated and easier to make scope mistakes.)
>> But this seems a bit clunky (compared to the elegance of GCD code),
>
> It's pretty much your only option. GCD doesn't have a notion of canceling a task, so you can only set a flag and check it.
Thanks, now I know.
> If at any point it evaluates to true, then you know somebody has set it or is in the process of setting it, which means it really is supposed to be true. In theory, yes, the code which is setting it may not have completed, but you don't care.
I undersand that, but I just wanted to be a purist :) Well, I will do
as Charles suggested: I will declare the property as atomic and
synthesize it.
Thanks to everyone!
_______________________________________________
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