Re: Persistent NSOperation?
Re: Persistent NSOperation?
- Subject: Re: Persistent NSOperation?
- From: Ken Thomases <email@hidden>
- Date: Mon, 21 Dec 2009 13:28:13 -0600
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@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