Re: Accuracy of NSThread sleepUntilDate
Re: Accuracy of NSThread sleepUntilDate
- Subject: Re: Accuracy of NSThread sleepUntilDate
- From: Marcel Weiher <email@hidden>
- Date: Fri, 3 Aug 2001 16:38:03 +0200
On Friday, August 3, 2001, at 03:03 Uhr, Christian Mike wrote:
I have a multithreaded application in which the threads will sometimes
delay
for a short time. I use the code:
NSTimeInterval timeInterval = (NSTimeInterval) someMilliseconds /
1000.0;
[NSThread sleepUntilDate:[NSDate
dateWithTimeIntervalSinceNow:timeInterval]];
Now I am not look for high accuracy here. I realize that when you give
up
the processor in a multithreaded application that all bets are off. I am
just looking for some ball park answer about how accurate this delay
mechanism is. What is a reasonably expected quantization unit here?
I have used this mechanism in my Squeak port to MacOS-X, which runs the
Squeak interpreter in a secondary thread. I was surprised to find that
the NSThread method very often sleeps for exactly the time specified, as
short as a couple of milliseconds.
So my recommendation would be to try this method, time it and see if it
works for you.
--
Marcel Weiher email@hidden
HOM: <
http://www.metaobject.com/downloads/Objective-C/>