Hi all,

I’m hoping somebody can help me work out how to protect my code against the 
effects of “app nap”. This code is driving a scientific experiment, unattended, 
and it is catastrophic when the OS decides that my timers running at 10Hz 
should only be fired every 10 seconds or so… which it turns out has been 
happening!

I have been calling [[NSProcessInfo processInfo] beginActivityWithOptions:…] 
from -applicationDidFinishLaunching. I know that a blanket declaration like 
this would typically be considered poor practice, but honestly if the program 
is running then the experiment is running and I need the OS not to mess with my 
timings to that extent. Anyway, that seems to help stop the timer weirdness. 
However, I was a bit surprised to find that I seem to need to explicitly retain 
the object I get back [this is non-ARC code…] if I want my request to remain in 
effect or even for the object to remain allocated to allow me to call 
endActivity at a later point. I wasn’t expecting to have to retain it, and 
there’s no explicit mention of that in the headers, so I just wanted to check 
that is to be expected, or whether I may be doing something weirdly wrong.

The other thing I wanted to ask relates to creating a timer using 
dispatch_source_create. I have tried to be flexible where I can in terms of 
providing a leeway for non-critical timers, but others I really want to have 
control over. For these I am specifying DISPATCH_TIMER_STRICT, also in the hope 
of dissuading the OS from trying to be too clever for its own good. I notice 
that using this flag leads to dispatch_source_create failing on 10.8.5, which I 
presume is because the flag is not recognised (or needed) on that OS version. 
My question here is what is the most appropriate way of identifying in code 
whether this feature is available, to ensure I only set it when it will be 
accepted.

Any help much appreciated!
Cheers
Jonny.
_______________________________________________

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