Re: Synchronous Serial Port Protocol messaging With NSOperationQueue/GCD
Re: Synchronous Serial Port Protocol messaging With NSOperationQueue/GCD
- Subject: Re: Synchronous Serial Port Protocol messaging With NSOperationQueue/GCD
- From: Ken Thomases <email@hidden>
- Date: Wed, 07 Aug 2013 10:36:03 -0500
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 (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