Re: Dispatch IO
Re: Dispatch IO
- Subject: Re: Dispatch IO
- From: Greg Parker <email@hidden>
- Date: Fri, 09 Aug 2013 12:37:19 -0700
On Aug 9, 2013, at 11:09 AM, Quincey Morris <email@hidden> wrote:
> Incidentally, keep in mind (from an earlier discussion on this list) that GCD semaphores initialized with a count greater than 0 will complain (incorrectly, IMO) if the current count is not the same as the initial count at deallocation time.
The assumption is that if you're destroying the semaphore and the count doesn't match then there is some worker still in progress that is going to signal the dead semaphore later. Detecting this error at semaphore destruction time instead of crashing at dead-semaphore signal time is a safety feature.
> The workaround is to create the semaphore with a zero count, and to immediately increment it to the desired value.
I believe this is exactly the intended solution. If you create with a positive count, you're assumed to be doing balanced operations. If the count starts at zero you can use whatever crazy unbalanced algorithms you like.
--
Greg Parker email@hidden Runtime Wrangler
_______________________________________________
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