> On 30 Mar 2016, at 18:35, Ken Thomases <k...@codeweavers.com> wrote:
> 
> On Mar 30, 2016, at 1:44 AM, Gerriet M. Denkmann <gerr...@mdenkmann.de> 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?

Sorry about this confusing pseudo code. The actual code is:

double delay1 = 50 * 1e-3;      //      50 msec in units of second


>> 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.  

Well, this might explain a shift in a timer doing its stuff by a small amount. 
Seems unlikely to explain a delay of several 10s of seconds. 

> Is your app otherwise active during those delays?

It is constantly sending messages to someOtherObjects and these 
someOtherObjects send back messages.

Each someOtherObject creates (at init) a sequential queue (socketQueue) and two 
socket descriptors (socket4FD  and socket6FD for ipv4 and ipv6 respectively) 
and binds these to some host/port; then does:
dispatch_source_create(DISPATCH_SOURCE_TYPE_WRITE, socket4FD, 0, socketQueue);
same for DISPATCH_SOURCE_TYPE_READ;
then adds dispatch_source_set_event_handlers for each dispatch_source.
Same for socket6FD.

But all activity of these someOtherObjects (which b.t.w. are a modified version 
of GCDAsyncUdpSocket) is done on its own sequential queue (socketQueue), which 
is ≠ commonSendQueue.
In sending back massages someOtherObject uses the main queue.
 
So it really should not have anything to do with the delay in commonSendQueue.

I just checked: same problem with 10.11.4.

Kind regards,

Gerriet.
_______________________________________________

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