Re: NSInvocationOperations and background Threads
Re: NSInvocationOperations and background Threads
- Subject: Re: NSInvocationOperations and background Threads
- From: Ken Thomases <email@hidden>
- Date: Sun, 18 Oct 2009 16:31:22 -0500
On Oct 18, 2009, at 7:26 AM, John Love wrote:
Thanks for your prompt reply, I really appreciate it.
You're welcome.
I have revamped my code to have just one NSInvocationOperation whose
selector contains the long for-loop. [...] the long for-loop is
within -doAllOperations.
OK, as far it goes.
It's my understanding from the docs and other Cocoa mailing list
readers that when -addOperation: is called, a new background Thread
is started up.
Well, you should stop trying to think about when exactly threads are
started up (or how many there are, or how long they run, or exactly
which one your operations run on, etc.). All of that is
implementation detail about which you shouldn't care. The only
important thing is that your (non-concurrent) operations will be run
on some background thread that you are not responsible for setting up
or managing. (If you implement concurrent operations, you still
aren't guaranteed anything about on which thread your -start method is
invoked, but you take responsibility for the execution context after
that.)
If that is true, then my long for-loop should be executing in the
background Thread. If I'm still on-track, then I have a problem in
that I temporarily placed a NSLog() call within my -doCalculation,
but nothing gets printed in my log. So, for the moment I am lost.
Well, there's no way for me to provide additional insight without
seeing your code. If you suspect your code is blocked, you can sample
your process (e.g. using Activity Monitor or the "sample" tool), which
can show you where your threads are spending their time. You can also
put may more logging statements throughout your code to track its
progress. You can break into your program in the debugger and examine
the various threads. Etc.
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