• 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: Observing Time
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Observing Time


  • Subject: Re: Observing Time
  • From: email@hidden
  • Date: Fri, 26 Jul 2013 23:16:44 +0900

On Jul 26, 2013, at 10:06 PM, Ken Thomases <email@hidden> wrote:

> On Jul 25, 2013, at 11:37 PM, email@hidden wrote:
>
>> On Jul 26, 2013, at 12:09 PM, Ken Thomases <email@hidden> wrote:
>>
>>> Also, the above code doesn't adjust the timer to fire on the second as Rick suggested.  You're asking it to fire every so many seconds (delayInSeconds) but you aren't specifying when during the second to fire.  Rather than passing 0 as the second parameter of dispatch_walltime(), you should compute an adjustment to try to get close to a whole second.  Since dispatch_walltime() uses gettimeofday() when you pass NULL for the first parameter, I'd use that same call to fill in a timeval structure and then pass NSEC_PER_SEC - (tp.tv_usec * NSEC_PER_USEC) as the second parameter.
>>>
>>> Regards,
>>> Ken
>>>
>> Thanks Ken, no I hadn't yet bothered to do this, as dispatch_walltime() was initially close enough to work on the other bits of the app.
>> It would make a difference to reduce some lag.
>> What is the part in the second parameter your are doing there…
>>> NSEC_PER_SEC - (tp.tv_usec * NSEC_PER_USEC)
>> Looks like something to adust it but what is tp.tv_usec ?
>
> I hypothesized a struct timeval variable named "tp" that you passed to gettimeofday().  Then you would use the sub-second part (the tv_usec field) to figure out roughly how far off of a whole second dispatch_walltime() would be when passed NULL for the first parameter, since it will also use gettimeofday().
>
> Regards,
> Ken
>
Ok yes, that much kind of made sense. But I'm not clear how I can know the delta from the whole second before it begins firing. (Honestly I've gotten my head a bit turned around by mach_time)
I'm going to have to spend some time to understand this I think.
_______________________________________________

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


References: 
 >Observing Time (From: email@hidden)
 >Re: Observing Time (From: Rick Mann <email@hidden>)
 >Re: Observing Time (From: email@hidden)
 >Re: Observing Time (From: Ken Thomases <email@hidden>)
 >Re: Observing Time (From: email@hidden)
 >Re: Observing Time (From: Ken Thomases <email@hidden>)

  • Prev by Date: Re: Observing Time
  • Next by Date: Re: Observing Time
  • Previous by thread: Re: Observing Time
  • Next by thread: Re: Observing Time
  • Index(es):
    • Date
    • Thread