Re: Strange Delay
Re: Strange Delay
- Subject: Re: Strange Delay
- From: Ken Thomases <email@hidden>
- Date: Wed, 30 Mar 2016 06:35:49 -0500
On Mar 30, 2016, at 1:44 AM, Gerriet M. Denkmann <email@hidden> wrote:
>
> This is done once (OS X 10.10.5):
> commonSendQueue = dispatch_queue_create( “common socket queue", DISPATCH_QUEUE_SERIAL);
>
> Several objects do this quite often:
>
> NSDate *dax0 = [ NSDate date ];
> dispatch_async(commonSendQueue, ^{ @autoreleasepool { [ someOtherObject doSomethingwithDate: dax0]; }});
>
> double delay1 = 50 msec
What does this mean? That's not valid code. What's the "msec" doing in there?
> NSDate *dax1 = [ NSDate dateWithTimeInterval: delay1 sinceDate: dax0 ];
> dispatch_time_t disTim1 = dispatch_time(DISPATCH_TIME_NOW, (int64_t)( delay1 * NSEC_PER_SEC));
Is delay1 in seconds or milliseconds? If the latter, then you're using it wrong in both of the above lines.
> dispatch_after(disTim1, commonSendQueue, ^{ @autoreleasepool { [ someOtherObject doSomethingwithDate: dax1]; }});
>
>
> someOtherObject does:
> - (void) doSomethingwithDate: (NSDate *)date
> {
> NSTimeInterval inDelay = -date.timeIntervalSinceNow * 1e3;
> if ( inDelay > 12 ) NSLog(@"%s in-delay %9.3f msec",__FUNCTION__, inDelay);
> }
>
> The in-delay is usually less than a dozen milliseconds.
>
> But in the call with dispatch_after (never with dispatch_async) the in-daly is sometimes is 10 seconds - sometimes even 20 or 30 seconds - mostly (but not always) near an integral multiple of 10 seconds.
>
> Why this delay of 10 seconds, and how can I find out, what is the cause of it?
> P.S. instead of dispatch_after I tried NSTimer and nanosleep. Same problem.
This may have something to do with App Nap or timer coalescing. Is your app otherwise active during those delays?
Regards,
Ken
_______________________________________________
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: | |
| >Strange Delay (From: "Gerriet M. Denkmann" <email@hidden>) |