On Aug 9, 2013, at 11:09 AM, Quincey Morris 
<quinceymor...@rivergatesoftware.com> 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     gpar...@apple.com     Runtime Wrangler



_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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 arch...@mail-archive.com

Reply via email to