On Wed, Sep 24, 2008 at 8:56 AM, Sandro Noel <[EMAIL PROTECTED]> wrote: > Greetings. > > I need a clarification about the NSOpration ans NSOperationQueue > > I read in the documentation that the NSOperation itself is non concurrent. > and that i can program it to be, if I override this and that method. and > configure the runtime env. > I assume that means create my own threads(NSTasks).
I am not sure if the last sentence above shows some confusion on thread and task or was just noting either could be used but just in case... NSTasks are processes each of which may have one or more threads. NSThreads are threads each of which has a thread stack, thread context, etc. A "concurrent" operation is called from the "managing" thread of the operation queue and it is left up to the operation on how it wants to execute its operation. For example it could do the computation directly when main is called but that would prevent the operation queue from moving on to another operation (likely defeats the purpose of using a queue and run contrary to the intent of returning true to isConcurrent). Or it could startup a thread or task to do the operation or fire off an async request, etc (more inline with the intent of isConcurrent) and return back to the operation queue (allowing it to move onto the next operation). A "non-concurrent" operation is called by a worker thread that the operation queue manages. This operation will then run in this worker thread and the operation queue can move onto other operations (since the operation queue managing thread isn't blocked). It basically means does the operation manage its own concurrency (isConcurrent = YES) or does the operation queue need to do it for the operation (isConcurrent = NO). > If I use NSOperation, override only the main method, I get a non concurrent > object to run a particular piece of code. > Stack these lovely objects in an operationQueue and set > setMaxConcurrentOperationCount to 4. > The Queue itself is the one managing the concurrency. and I will have 4 > operations runing at the same time? Correct.... assuming your operations don't state dependencies that prevent concurrency, the system has the ability to execute 4 threads (enough physical or virtual "cores", aka hyper threading) and current system pressure doesn't prevent reaching max concurrency. -Shawn _______________________________________________ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]