Re: NSRunLoop
Re: NSRunLoop
- Subject: Re: NSRunLoop
- From: vincent habchi <email@hidden>
- Date: Tue, 15 Jun 2010 08:33:58 +0200
Le 15 juin 2010 à 00:41, Jean-Daniel Dupas a écrit :
>
> Le 15 juin 2010 à 00:22, Ariel Feinerman a écrit :
>
>> Hi,
>> I wish to make programme has cpu-related (one thread per core) number of
>> worker threads. When user inputs the data, main thread splits up the data
>> and send to the workers. Then worker threads go to sleep in anticipation of
>> the next chunk of data. How can I do it? I think to NSRunLoop is the best
>> way, is the example of code?
>>
>
> I guess that if you ask this, you need to deploy on Mac OS 10.5 or older, else instead of bothering with your own thread pool, just use GCD.
> If you want to do that for 10.5, use NSOperationQueue.
You can also use mutexes (NSLock) or semaphores to synchronise your code; typically, the systems puts to sleep any thread that is waiting for a lock, so it does not waste CPU power. Your main thread acquires lock, write buffers, and when it's time it releases the lock that the auxiliary thread acquire, consume the data, then release the lock and so on.
Vincent_______________________________________________
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
References: | |
| >NSRunLoop (From: Ariel Feinerman <email@hidden>) |
| >Re: NSRunLoop (From: Jean-Daniel Dupas <email@hidden>) |