On Dec 21, 2009, at 11:26 AM, McLaughlin, Michael P. wrote:

> Could anyone point me to sample code that shows how to implement a
> persistent NSOperation that could be enqueued repeatedly?

You can't.  It's a fundamental part of the design of NSOperation.

It's not just that support for it was left out of the design.  In 
multi-threaded coding, it is sometimes very important that certain state 
changes can only go in one direction (not cancelled -> cancelled, not executing 
or finished -> executing and not finished -> not executing and finished, etc.). 
 It is very likely that NSOperationQueue would break if an NSOperation could 
change state in the other direction.


> Currently, I initialize NSOps just prior to launching but this involves
> copying large datasets (to avoid R/W contention) and it would be more
> efficient if I could initialize a fixed set of NSOps just once and reuse
> them.

Make your NSOperations have a relationship to some other object which holds the 
state that persists.  Serially create NSOperations which each have a 
relationship to this persistent state object, one after the other.

Regards,
Ken

_______________________________________________

Cocoa-dev mailing list ([email protected])

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to