>> 
> 
> Thanks, Ken. The reason I'm using a custom operation queue instead of GCD is 
> that I need to permit only exclusive access to the device (e.g., to obtain 
> its status requires writing to it), but allow other operations enqueued to 
> use the device, not just the status checks. So I have an NSOperationQueue 
> that has maxConcurrentOperationCount set to 1, but I need a status-check 
> operation to be automatically queued up 1 minute after the last one has run.
> 
> So, if the device is accessed otherwise the status checks won't interfere 
> with that because only 1 operation can be active in the queue, thus 
> everything stays well ordered and exclusive access is permitted to all, one 
> at a time. I just can't figure a way to have the status check operation 
> trigger another one to be magically enqueued 60 seconds later.
> 
> -Carl


Quite a few ways to skin that cat. 

Make every operation complete by adding a cleanup operation block to the queue. 
Have that block do nothing for 60 seconds but check the number of operations in 
the queue on a regular basis, if the number of operations rises above one, 
exit, if it gets to 60 seconds, perform cleanup. Wasteful but easy. 

Make a dispatch_timer, just one, have the start of every operation set the 
timer to the distant future, at the end set it to 60 seconds, have the 
dispatch_timer toss the cleanup block on your queue. Or do a 
dispatch_test_cancel() at the start of the block, and set the timer to 60 
seconds and dispatch_resume() at the end of the block, either works. 60 seconds 
after the last block finished executing, your cleanup block will run. 
_______________________________________________

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