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: Fri, 5 Dec 2008 16:24:53 +0100
Le 5 déc. 08 à 16:00, Påhl Melin a écrit :
2008/12/5 Benjamin Stiglitz <email@hidden>:
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?
alarm(3) or setitimer(2).
setitimer(2) could be used if I calculate the relative difference
between multiple timer settings and resetting to the next interval
after each signal. Some extra work but doable. When using multiple
timers the alarms could possible start to drift I suppose.
But I got the impression from Jean-Daniel Dupas, that kevent() with
the timer filter EVFILT_TIMER is implemented even though the man page
of kqueue(2) says "EVFILT_TIMER This filter is currently unsupported."
Do you know from which OS X version kevent() timers are supported? Or
if they are officially supported at all?
They are commented out in 10.3.9 sources, and implemented in 10.4.0
sources.
I guess than man page has not been updated at this time.
...and how do you setup multiple timer events? In the kqueue(2) man
page for OpenBSD 4.3 it says: "EVFILT_TIMER Establishes an arbitrary
timer identified by ident..." Is the timer identifier something you
(as in: me the programmer) selects randomly for the struct kevent{} 's
ident member field or do I generate the id with some library call
beforehand?
_______________________________________________
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