I have a thread that is invoked with:

[NSThread detachNewThreadSelector:@selector(threadMethod:) toTarget:self
withObject:self];

It uses NSConditionLock and works well.

This thread performs a complex process but does it slowly so as to not use
much processor time. I specify how long I want it to take (1 to 30 minutes)
and use:

//  block this task until time has elapsed or an exit signal is received.
if ([[self lock] lockWhenCondition:kConditionThreadMustExit beforeDate:[self
blockUntil]])      
     [[self lock] unlock];

blockUntil simply checks to see how much work has been done vs how much time
has passed and if 50% of the work has been done, blocks until 50% of the
time has passed. It works well since the work is very linear.

I would like to move this to NSOperation and NSOperationQueue but I see no
way to replicate this behavior. My current thread is limited to a single
processor core and with NSOperation I could split it to multiple cores, but
in so doing I seem to lose this "delay for a while" bit.

Any ideas?

Thanks.



_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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

This email sent to arch...@mail-archive.com

Reply via email to