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
NSDate *dax1 = [ NSDate dateWithTimeInterval: delay1  sinceDate: dax0 ];
dispatch_time_t disTim1 = dispatch_time(DISPATCH_TIME_NOW, (int64_t)( delay1 * 
NSEC_PER_SEC));
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?

A breakpoint in doSomethingwithDate shows:

* thread #12: tid = 0x341eb, 0x0000000100012a43 gLifx`-[GCDAsyncUdpSocket 
doSomethingwithDate:](self=0x00006180001e7300, _cmd=“ doSomethingwithDate:", 
date=2016-03-30 06:34:00 UTC) + 179 at GCDAsyncUdpSocket.m:1851, queue = 
'common socket queue', stop reason = breakpoint 1.1
— 
  * frame #0: 0x0000000100012a43 gLifx`-[GCDAsyncUdpSocket 
doSomethingwithDate:](self=0x00006180001e7300, _cmd="doSomethingwithDate:", 
date=2016-03-30 06:34:00 UTC) + 179 at GCDAsyncUdpSocket.m:1851
    frame #1: 0x00000001000830ea gLifx`__52-[LFXUDPGatewayConnection 
sendNextMessageFromOutbox]_block_invoke186(.block_descriptor=0x00006000000852d0)
 + 138 at LFXUDPGatewayConnection.m:359
    frame #2: 0x000000010018c989 
libdispatch.dylib`_dispatch_call_block_and_release + 12
    frame #3: 0x0000000100187fc3 libdispatch.dylib`_dispatch_client_callout + 8
    frame #4: 0x000000010019cd40 
libdispatch.dylib`_dispatch_after_timer_callback + 322
    frame #5: 0x0000000100187fc3 libdispatch.dylib`_dispatch_client_callout + 8
    frame #6: 0x0000000100196b20 
libdispatch.dylib`_dispatch_source_latch_and_call + 1239
    frame #7: 0x000000010018df1c libdispatch.dylib`_dispatch_source_invoke + 425
    frame #8: 0x000000010018c471 libdispatch.dylib`_dispatch_queue_drain + 1002
    frame #9: 0x000000010018bf28 libdispatch.dylib`_dispatch_queue_invoke + 223
    frame #10: 0x000000010018b9de libdispatch.dylib`_dispatch_root_queue_drain 
+ 666
    frame #11: 0x000000010018b73c libdispatch.dylib`_dispatch_worker_thread3 + 
106
    frame #12: 0x00007fff91241a9d libsystem_pthread.dylib`_pthread_wqthread + 
729
    frame #13: 0x00007fff9123f3dd libsystem_pthread.dylib`start_wqthread + 13
(lldb) 


Gerriet.

P.S. instead of dispatch_after I tried NSTimer and nanosleep. Same problem.
I also removed the autorelasepool - made no difference.



_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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 arch...@mail-archive.com

Reply via email to