• 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: repeating timer with "run now"
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: repeating timer with "run now"


  • Subject: Re: repeating timer with "run now"
  • From: Jean-Daniel Dupas <email@hidden>
  • Date: Thu, 22 Aug 2013 15:48:15 +0200

Le 22 août 2013 à 15:36, Torsten Curdt <email@hidden> a écrit :

> I have some piece of code that I want to run every x seconds ....but I
> also want to be able to trigger a "run now" that will reset the
> upcoming cycle.
>
> I think I would know plenty of ways to implement this (ranging from
> simple NSTimer to select() style signaling to threading with
> conditions) but I am looking for the most elegant way - preferably
> with GCD.
>
> Scheduling a block is easy with GCD - but can you also notify that
> block for immediate execution later on?
>
> Just would love to hear opinions on how you would tackle this
> admittedly easy problem the most elegant way.


Why not just keeping a reference on your scheduled block and simply call dispatch_async when you want to execute it immediately ?

-- Jean-Daniel





_______________________________________________

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: repeating timer with "run now"
      • From: Torsten Curdt <email@hidden>
References: 
 >repeating timer with "run now" (From: Torsten Curdt <email@hidden>)

  • Prev by Date: repeating timer with "run now"
  • Next by Date: Re: repeating timer with "run now"
  • Previous by thread: repeating timer with "run now"
  • Next by thread: Re: repeating timer with "run now"
  • Index(es):
    • Date
    • Thread