Re: Asynchronous timers (without a run loop)
Re: Asynchronous timers (without a run loop)
- Subject: Re: Asynchronous timers (without a run loop)
- From: Jean-Daniel Dupas <email@hidden>
- Date: Thu, 4 Dec 2008 14:38:58 +0100
Le 4 déc. 08 à 14:00, Påhl Melin a écrit :
Yes, I could set up a new thread, handling a list of usleep()
intervals between the actual timer events but it would be very hard to
make a reliable, drift-free timer service, handling lots of timer
events and it would take quite some time to develop a fully functional
and reliable version. I really hope I don't have to...
In the Kernel Programming Guide in ADC, chapter 7, Mach Overview, Time
Management, it says:
"The mach_timespec_t API is deprecated in Mac OS X. The newer and
preferred API is based on timer objects
that in turn use AbsoluteTime as the basic data type. AbsoluteTime is
a machine-dependent type, typically
based on the platform-native time base. Routines are provided to
convert AbsoluteTime values to and from
other data types, such as nanoseconds. Timer objects support
asynchronous, drift-free notification, cancellation,
and premature alarms. They are more efficient and permit higher
resolution than clocks."
Does anyone know about this "new API" or any higher level API build on
it? I sounds like a good candidate for my project.
/ Påhl
2008/12/4 Nathan Day <email@hidden>:
NSRunLoop use to be based on the function select() (it was in GnuStep
anyway), it waits for inputs but also has a single timeout value
also,
NSRunLoop works out how long the timeout value should be for the
shortest
NSTimer. If you want to wait on multiple timers without using run
NSRunLoop
then you will have to implement this kind of functionality
yourself. You can
then just use sleep() to make your thread wait.
On 04/12/2008, at 9:32 PM, Påhl Melin wrote:
I need to use timers in a low level library where I need to specify
asynchronous callbacks to a timer function. I will not have any run
loop so I cannot use NSTimer. Are there any low level timer API to
use
instead? I haven't found anything useful (yet) on google nor ADC. I
assume there must exist some Mach or BSD level API:s that can be
used?
Any suggestions?
If you want to avoid Cocoa, Cocoa-dev is probably not the best mailing
list to ask.
You will have more chance on darwin-dev.
What do you mean by "low-leve" ? What prevent you to use NS classes ?
Is this contraint preventing you to use CoreFoundation ? (which is
low-level IMHO).
If you want lower level primitive, you can use kevent's timers, or if
you want really low-level, there is a mach timer API, but I don't
think it is considere public as the header cannot be found in /usr/
include/mach
Anyway, that's the API used in CoreFoundation for CFTimer and declared
in mk_timer.h (see XNU sources for details). But I wont go this way in
a shipping product.
_______________________________________________
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