• 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
Re: Asynchronous timers (without a run loop)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Asynchronous timers (without a run loop)


  • Subject: Re: Asynchronous timers (without a run loop)
  • From: Joseph Kelly <email@hidden>
  • Date: Thu, 04 Dec 2008 06:50:19 -0800

I've used both the CF and NS timer apis in many different situations without a hitch. They're fairly reliable. Perhaps you could explain your "can't use a runloop" restriction -- e.g. if you are writing a daemon or a kext, this is not the list you want to post to.

You might find if you refactor your design a bit, that it will take to a runloop model quite well. In fact, most of the user space IOKit async routines require that you use a runloop.

Also, the Mach APIs are not strictly private -- the headers are publicly available. They are subject to change between releases, so if you do start using them, you will need to stay on top of things -- check your binaries on pre-release OS seeds etc.

Joe K.

On Dec 4, 2008, at 6:17 AM, Påhl Melin wrote:

2008/12/4 Jean-Daniel Dupas <email@hidden>:
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.

I don't want to avoid Cocoa, but I just haven't found any Cocoa class that supports timers without a run loop. But maybe I need to switch to 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).

Nothing prevents me from using NS classes per se. I will use the timers in a C++ class and want to get a callback to a normal function—not calling a selector on an Objective-C class that most NS classes would do. And since it's supposed to be the lowest level of my architecture I want it to be as efficient as possible.

The only problem I have is that I will run the timers on threads
without run loops so both NSTimer and CFRunLoopTimer (I didn't find
any reference information about CFTimer on ADC) are impossible to use.

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

In the man page for kevent it says that kevent timers are not supported ("EVFILT_TIMER This filter is currently unsupported."). I just assumed that the man page was correct and haven't made any tests. Are you sure kevent timers are implemented in Mac OS X? When it comes to Mach timers I wouldn't dare to use that in a commercial product since Apple seems to ask developers to keep away from 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.

Agree... I will keep away from any private API:s.

_______________________________________________

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


  • Follow-Ups:
    • Re: Asynchronous timers (without a run loop)
      • From: "Påhl Melin" <email@hidden>
References: 
 >Asynchronous timers (without a run loop) (From: "Påhl Melin" <email@hidden>)
 >Re: Asynchronous timers (without a run loop) (From: Nathan Day <email@hidden>)
 >Re: Asynchronous timers (without a run loop) (From: "Påhl Melin" <email@hidden>)
 >Re: Asynchronous timers (without a run loop) (From: Jean-Daniel Dupas <email@hidden>)
 >Re: Asynchronous timers (without a run loop) (From: "Påhl Melin" <email@hidden>)

  • Prev by Date: Re: Programmatically loading an NSImage via other field
  • Next by Date: Webview and streaming data
  • Previous by thread: Re: Asynchronous timers (without a run loop)
  • Next by thread: Re: Asynchronous timers (without a run loop)
  • Index(es):
    • Date
    • Thread