Re: NSOperationQueue question
Re: NSOperationQueue question
- Subject: Re: NSOperationQueue question
- From: Quincey Morris <email@hidden>
- Date: Fri, 7 Aug 2009 14:30:49 -0700
On Aug 7, 2009, at 14:06, Tim Murison wrote:
The improved code will execute about 1000 operations as quickly as
possible,
then it will sleep for 1 second. Before sleeping, it will print the
operation queue length, proving that the queue doesn't grow for ever
(it is
always < 5000 on my machine). Finally, the long sleep means that CPU
use is
low giving GC plenty of time to do its work (even without the [pool
drain]
hint.) Each iteration of the loop will attempt to collect the garbage.
That's not how I read it. The code will flood the operation queue
until 1000 operations have incremented the counter (which is almost,
but not quite, the same thing as saying that 1000 operations have
finished executing).
At that point, there may be many thousands of pending operations still
to be executed. That's not a quiescent state. You need to stop queuing
operations, then wait for the queue to empty and wait for all
operation threads to cease existing and wait for the garbage collector
to run as many times as it wants until it has nothing left to collect,
and *then* you have a quiescent state.
_______________________________________________
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