Re: Is a serial NSOperationQueue FIFO?
Re: Is a serial NSOperationQueue FIFO?
- Subject: Re: Is a serial NSOperationQueue FIFO?
- From: Chris Kane <email@hidden>
- Date: Wed, 16 Sep 2009 13:41:17 -0700
On Sep 6, 2009, at 9:32 PM, Eric Hermanson wrote:
When working with a serial NSOperationQueue (i.e.
setMaxConcurrentOperationCount==1), are the operations added to the
queue guaranteed to run in FIFO order if all operations have the
same priority and no operation dependencies are involved? My guess
is that the NSOperationQueue will run the operations in FIFO order,
however, I don't believe the NSOperationQueue documentation
guarantees this. The documentation says operations will run based
on priority, then on dependency structure. Because all operations
in this aforementioned serial queue have the same priority (i.e
normal) and no dependencies, then I suppose the NSOperationQueue
could sort the operations any way it wanted, not necessarily in the
order I added them to the queue.
Does anyone have insight into this, or is there documentation
anywhere that can guarantee to me an NSOperationQueue with a
concurrent operation count of 1 will indeed process the operations
first come first serve?
If all operations have the same priority (which is not changed after
the operation is added to a queue) and all operations are always -
isReady==YES by the time they get put in the operation queue, then a
serial NSOperationQueue is FIFO. The second condition I mention there
is stronger than "no operation dependencies" -- dependencies don't
directly matter to a queue, just the readiness of the operations, and
dependencies are just one thing that can affect readiness.
If you are adding NSOperations to a given queue from multiple threads,
keep in mind that it is very tricky (well, impossible) to accurately
observe from the outside the actual order of events (ie, who got in
first).
Chris Kane
Cocoa Frameworks, Apple
_______________________________________________
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