On Mar 30, 2016, at 1:44 AM, Gerriet M. Denkmann <[email protected]> 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 protected])
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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]