Re: Observing Time
Re: Observing Time
- Subject: Re: Observing Time
- From: email@hidden
- Date: Sun, 28 Jul 2013 08:53:32 +0900
On 2013/07/28, at 1:35, Kyle Sluder <email@hidden> wrote:
> On Sat, Jul 27, 2013, at 09:16 AM, email@hidden
> wrote:
>>
>> On 2013/07/28, at 0:38, Scott Ribe <email@hidden> wrote:
>>
>>> On Jul 27, 2013, at 9:15 AM, email@hidden wrote:
>>>
>>>> But I'm avoiding NSTimer because I want to avoid being run looped in completely
>>>
>>> Why??? If the run loop on the main thread is busy, your display won't update anyway. I think you're adding a lot of complexity for 0 gain.
>> Why would I add to slowing down the main thread when I can run a
>> dispatch_timer on another thread and get the timer to fire more reliably?
>> That doesn't make sense.
>
> More threads != more better.
One more thread.
Really, surprised by this as I never said anything about more threads being better. Only that I don't want this timer on the main run loop.
>
> You're drawing on the main thread. Firing the timer on a background
> thread gets you _zero_ benefit, because you have to forward those timer
> pulses to the main thread anyway!
I just tried both approaches and guess which one stays right there with the menu bar clock and which one lags?
dispatch timer is the winner.
And it's not doing a lot.
I built a test app for each approach to verify.
In each timer I set an NSDate property to the latest date, and set the stringValue on an NSTextField.
I'm not using bindings.
Maybe I should try a different run loop mode than default for NSTimer?
Happy to hear suggestions here, but I see dispatch timer giving the precision desired and I don't feel like its costing me anything to accomplish.
As per the docs, NSTimer gives millisecond accuracy, but can fire some undetermined time after the set fire interval.
>
> --Kyle Sluder
_______________________________________________
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