New question about borken NSOperationQueue
New question about borken NSOperationQueue
- Subject: New question about borken NSOperationQueue
- From: email@hidden
- Date: Sat, 31 Jan 2009 15:40:08 -0500 (EST)
- Importance: Normal
I have a computationally intensive modeling application which I NEED to
multi-process, I am trying to avoid low level calls to pthread and tcb
block.
In order to get my GUI running I had to create a NSOperationQueue and run
my big method via a NSInvocationOperation.
Previous post indicates that NSOperationQueue only seems to work with ONE
queue. So it seems that I can either have GUI working OR do
multi-processing...
The key is the waitUntilAllOperationsAreFinished method of MSOperationQueue.
I create a NSOperationQueue in my intialization process in my
appController class.
I have a method triggered by user pushing button which calls:
- (IBAction)launchEvolveTask:(id)sender
{
NSInvocationOperation* bigOp = [[NSInvocationOperation alloc]
initWithTarget:self selector:@selector(evolve:) object:nil];
[myOpQueue addOperation:bigOp];
}
NOW in my evolve: method I have nested loops:
for(i = 0; i < MAX_GENS; i++)
{
for(j = 0; j < NUM_MEMBERS; j++)
{
member = [someArray objectAtIndex:j];
NSInvocationOperation *concurrentOp = [NSInvocationOperation
initWithTarger:member selector:processStuff:
object:sharedDataArray];
[[appController opQueue] addOperation:concurrentOp];
}
[opQueue waitUntilAllOperationsAreFinished]; <-----
}
***** above method HAS to wait for the bigOp to finish too, which makes
the wait operation useless.
The only solution I have come up with so far is to launch my evolve:
NSInvocationOperation directly with the start method, This means GUI
locks.
If I nest another NSOperationQueue instead of using appController's
NSOperationQueue the BUG forces a crash every time.
Evidently this is a KNOWN bug which is supposed to be fixed in 10.6
I am going to implement my own pthreads with a tcb block to go low-level
on this problem, but would LOVE to be able to use Apples high-level tools.
Any advice is welcomed.
Thankyou,
Ron
_______________________________________________
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