• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSThread sleepUntilDate w/ dateWithTimeIntervalSinceNow and intervals < 1sec
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSThread sleepUntilDate w/ dateWithTimeIntervalSinceNow and intervals < 1sec


  • Subject: NSThread sleepUntilDate w/ dateWithTimeIntervalSinceNow and intervals < 1sec
  • From: Nicolas Berloquin <email@hidden>
  • Date: Sun, 30 Oct 2005 21:28:04 +0100

Hello !

I have a background thread that needs to loop every 25ms.
After each loop, I calculate the time spent inside the loop, then call :

[NSThread sleepUntilDate: [NSDate dateWithTimeIntervalSinceNow: ]];

with a value between ]0;25ms]. But I'm getting strange offsets in what
should be a continuous heartbeat.

The docs talk about :
+ (id)dateWithTimeIntervalSinceNow:(NSTimeInterval)seconds

NSTimeInterval being a double, I assumed I could pass miliseconds,
or even microseconds. Does it actually round the parameter to the nearest
second ?


If this is the case, which is the best way to sleep an NSThread less than 1 sec
without rewriting the code to use some other kind of threading mechanism ?
(I really like the one-line call to launch it and manage it !)


thanks

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: NSThread sleepUntilDate w/ dateWithTimeIntervalSinceNow and intervals < 1sec
      • From: Pontus Ilbring <email@hidden>
  • Prev by Date: IB not updating header file
  • Next by Date: Re: IB not updating header file
  • Previous by thread: Re: IB not updating header file
  • Next by thread: Re: NSThread sleepUntilDate w/ dateWithTimeIntervalSinceNow and intervals < 1sec
  • Index(es):
    • Date
    • Thread