On Aug 7, 2013, at 2:20 AM, Tom Davie wrote:

> My suggestion would instead be to make an NSOperation subclass for sending a 
> message to the device.
> 
> That subclass should require you to specify to which device you are talking.  
> Each device object should carry around a dispatch_semaphore.  When a message 
> is sent, the semaphore should be checked and set to stop any other operations 
> proceeding until the semaphore is unset.  When the device responds, the 
> semaphore should be unset.
> 
> You can then make your operation queue a concurrent queue, rather than a 
> serial one, so that you can send messages to more than one device at the same 
> time, while still maintaining your one-thing-at-a-time per device rule.

Why would you do that?  Operation queues are cheap.  Have one serial queue per 
device.  There's little reason to add another synchronization method on top of 
operations to cause them to serialize with respect to one another.

Regards,
Ken


_______________________________________________

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