Re: How to Delay, Wait, Pause...

2008-05-25 Thread Steve Steinitz
Hi Jens, Thank you for your clarifications. I had been left with an unsettled feeling about the technique. On 25/5/08, Jens Alfke wrote: > On 25 May '08, at 2:40 AM, Thomas Davie wrote: > > >I hate to say this, but any form of delay here is the *wrong* > >way to do this. You already know yo

Re: How to Delay, Wait, Pause...

2008-05-25 Thread Jens Alfke
On 25 May '08, at 2:40 AM, Thomas Davie wrote: I hate to say this, but any form of delay here is the *wrong* way to do this. You already know you have a race condition, all you're doing is making it so the race condition will work out in your favor 99.99% of the time. There are still exc

Re: How to Delay, Wait, Pause...

2008-05-25 Thread Steve Steinitz
Hi Dimitri, Thanks for your insightful reply. On 25/5/08, Dmitri Goutnik wrote: Have to agree with Thomas that delay is the wrong way to handle this. Yes, he makes a good point. From 10.4 on fetch: results are delayed until the next iteration of the run loop so (please correct me if I'm wr

Re: How to Delay, Wait, Pause...

2008-05-25 Thread Steve Steinitz
Hi Ken, On 25/5/08, Ken Thomases wrote: Just for posterity, there's also the simpler, more efficient [NSThread sleepForTimeInterval:0.1]. The documentation says it's only available in 10.5 and later, but the 10.5 release notes say that it was always available but only recently published in the

Re: How to Delay, Wait, Pause...

2008-05-25 Thread Steve Steinitz
Hi Bob at [EMAIL PROTECTED] (Thomas Davie) On 25/5/08, Thomas Davie wrote: I hate to say this, but any form of delay here is the *wrong* way to do this. You already know you have a race condition, all you're doing is making it so the race condition will work out in your favor 99.99% of the tim

Re: How to Delay, Wait, Pause...

2008-05-25 Thread Dmitri Goutnik
Sorry, forgot to hit Reply All.. On May 25, 2008, at 10:45 AM, Steve Steinitz wrote: Hello, This is hard to google for because they are such common words: how do I delay, wait, pause for a tenth of a second? I don't want to use NSTimer because I just want to resume where I left off. I don

Re: How to Delay, Wait, Pause...

2008-05-25 Thread Michael Vannorsdel
This is an important consideration. If you're relying on a specific event to finish within a finite amount of time, you're going to have a race condition where the event could finish later than expected and you may end up in an invalid state. Perhaps if you told us what it is you're specif

Re: How to Delay, Wait, Pause...

2008-05-25 Thread Ken Thomases
On May 25, 2008, at 4:22 AM, Steve Steinitz wrote: NSDate *future = [NSDate dateWithTimeIntervalSinceNow: 0.1]; [NSThread sleepUntilDate:future]; Just for posterity, there's also the simpler, more efficient [NSThread sleepForTimeInterval:0.1]. The documentation says it's only availabl

Re: How to Delay, Wait, Pause...

2008-05-25 Thread Thomas Davie
On 25 May 2008, at 11:22, Steve Steinitz wrote: Hello, Thank you Jens Alfke, Peter Burtis and Stephen Joseph Butler for your excellent, quick and helpful replies. [SNIP] from your method. Stephen warns that the host method needs to be re- entrant or guard against multiple entries. I

Re: How to Delay, Wait, Pause...

2008-05-25 Thread Steve Steinitz
Hello, Thank you Jens Alfke, Peter Burtis and Stephen Joseph Butler for your excellent, quick and helpful replies. Thank you Jens for the heads up about the threading and for letting me know that things are done this way in Cocoa -- I just didn't want to be out in left field. Below. for fu

Re: How to Delay, Wait, Pause...

2008-05-25 Thread stephen joseph butler
On Sun, May 25, 2008 at 1:45 AM, Steve Steinitz <[EMAIL PROTECTED]> wrote: > Hello, > > This is hard to google for because they are such common words: > > how do I delay, wait, pause for a tenth of a second? Hmm... someone correct me if I'm wrong, but I believe the run loop is re-enterable. So you

Re: How to Delay, Wait, Pause...

2008-05-25 Thread Michael Vannorsdel
There's usleep, but sleeping a thread just for a very small amount of time in a loop is gonna force a context switch every iteration and really hurt performance. It might be better to poll or spin. On May 25, 2008, at 12:45 AM, Steve Steinitz wrote: This is hard to google for beca

Re: How to Delay, Wait, Pause...

2008-05-25 Thread Jens Alfke
On 24 May '08, at 11:45 PM, Steve Steinitz wrote: I don't want to use NSTimer because I just want to resume where I left off. I don't want to be in a tight loop because I need the system to finish something. I just want to pause execution for a short time. I think there was a wait() in

Re: How to Delay, Wait, Pause...

2008-05-24 Thread Peter Burtis
NSThread has a sleepUntilDate: class method. In the example below, 0.1 = 1/10th of a second. NSDate *future = [NSDate dateWithTimeIntervalSinceNow: 0.1 ]; [NSThread sleepUntilDate:future]; -Pete On May 25, 2008, at 2:45 AM, Steve Steinitz wrote: Hello, This is hard to googl

How to Delay, Wait, Pause...

2008-05-24 Thread Steve Steinitz
Hello, This is hard to google for because they are such common words: how do I delay, wait, pause for a tenth of a second? I don't want to use NSTimer because I just want to resume where I left off. I don't want to be in a tight loop because I need the system to finish something. I just wan