• 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: make sure one timer fire before another
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: make sure one timer fire before another


  • Subject: Re: make sure one timer fire before another
  • From: Andrei Tchijov <email@hidden>
  • Date: Mon, 29 May 2006 16:05:16 -0400

Alternatively, if your longest time interval is whole number of shortest time intervals ( like 2 sec is 2x1sec, 4s is 8x0.5 sec), you can use one timer scheduled for shortest interval and fire "longer interval" code when it is appropriate ( in case of 1sec and 2 sec, every second time, in case of 0.5 sec and 4 sec, every 8th time ).

On May 29, 2006, at 3:43 PM, Ed Wynne wrote:


On May 29, 2006, at 2:51 PM, Nir Soffer wrote:

I need two timers in a run loop, one should fire every second or so, and the other may fire every 2 seconds or more. How can I make sure that the 1 second timer fire always before the 2 seconds timer, even if both are scheduled for the same fire date?

I need a solution I can easy tune later - the second timer may repeat at the same rate or more then the first, but I may want to change the fire interval of both, e.g use 0.5s and 4s as needed.

If you really need strict ordering, your best solution would be to just use one timer (call it a physical timer) with a manually computed next fire date base on a secondary list of virtual timers (your own data structure). Every time your one physical timer fires, you sample the current time and service any virtual timers that have expired, then you recompute the next expiration base on the next closest deadline from the virtual list. If you deterministically process your list of virtual timers, you can enforce ordering any way you wish.


-Ed

_______________________________________________
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

_______________________________________________ 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
References: 
 >make sure one timer fire before another (From: Nir Soffer <email@hidden>)
 >Re: make sure one timer fire before another (From: Ed Wynne <email@hidden>)

  • Prev by Date: NSMatrix -objectValue always gives 1. What good is that?
  • Next by Date: Re: Installer Check to see if it's an Intel Mac
  • Previous by thread: Re: make sure one timer fire before another
  • Next by thread: NSMatrix -objectValue always gives 1. What good is that?
  • Index(es):
    • Date
    • Thread