Re: Pausing an NSThread

2009-11-09 Thread Jens Alfke
On Nov 8, 2009, at 2:17 AM, Roland King wrote: Or look at NSOperation/NSOperationQueue which absolves you of the need to care about threads, it's done for you (and I believe makes use of Grand Central Dispatch on current versions of OSX). Just package up whatever it is you need to do and s

Re: Pausing an NSThread

2009-11-08 Thread Ron Fleckner
Many thanks to all who helped with this. I've had some very useful discussion off-list with Roland King and I'm on my way to threading nirvana. Ron ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or modera

Re: Pausing an NSThread

2009-11-08 Thread Roland King
On 08-Nov-2009, at 5:37 PM, Ron Fleckner wrote: Hi Greg, thanks for the link. I think I've learned that the effect of pausing a thread can be just as easily and more safely achieved by simply stopping it depending on a BOOL on the main thread. Yes? So, in my situation, I would send

Re: Pausing an NSThread

2009-11-08 Thread Ron Fleckner
On 08/11/2009, at 4:34 PM, Greg Guerin wrote: Ron Fleckner wrote: I've finally worked out a way to pause a thread and would like to know if what I'm doing is dangerous or bad or...? Exactly what problem are you trying to solve? Pausing a thread is always potentially dangerous. Any locks

Re: Pausing an NSThread

2009-11-07 Thread Greg Guerin
Ron Fleckner wrote: I've finally worked out a way to pause a thread and would like to know if what I'm doing is dangerous or bad or...? Exactly what problem are you trying to solve? Pausing a thread is always potentially dangerous. Any locks or @synchronized blocks acquired before reachin

Re: Pausing an NSThread

2009-11-07 Thread Ron Fleckner
On 08/11/2009, at 2:36 PM, Dave DeLong wrote: Instead of a BOOL on the main thread, what about an NSLock? Start off by locking it on the main thread, and then the secondary thread can try to lock it, block (because it can't acquire the lock since the main thread has it), and not resume un

Re: Pausing an NSThread

2009-11-07 Thread Kyle Sluder
On Sat, Nov 7, 2009 at 7:28 PM, Ron Fleckner wrote: > This is a small proof-of-concept/test kind of project. I've had a look at > NSConditionLock, but I don't get the concepts.  So I've got this naïve > solution, which is a kind of polling, I know, but it _seems_ to work quite > well.  The CPU usa

Re: Pausing an NSThread

2009-11-07 Thread Dave DeLong
Instead of a BOOL on the main thread, what about an NSLock? Start off by locking it on the main thread, and then the secondary thread can try to lock it, block (because it can't acquire the lock since the main thread has it), and not resume until the main thread unlocks it (equivalent to t