Skip to content
CinderBlock to access Activity APIs added in OS X 10.9 to tie into App Nap
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
include
src
.gitignore
LICENSE
README.md
TODO.md
cinderblock.xml

README.md

Cinder-AppNap

Cinder-AppNap is a CinderBlock to access the Activity APIs introduced in OS X 10.9.

OS X 10.9 uses heuristics to improve system battery life, performance and responsiveness and governs the resources made available to applications and their behavior to achieve this. At times the system behavior isn't desirable and Cinder-AppNap can be used to hint an exceptional need. Doing so can obviously negatively affect the battery life, performance and responsiveness of the system as a whole, so one should be critical of its use and disciplined in minimizing its use to a narrow scope.

While the CinderBlock is (perhaps poorly) named Cinder-AppNap, an application can provide hints that affect other behaviors like timer coalescing and the application termination. Cinder-AppNap currently disables idle system sleep and sudden termination which is hopefully a fit for most Cinder application needs, but could certainly be made more flexible should the need arise.

NOTE - The exceptional need hint can be sent from Cinder, via AppBase::Settings::setPowerManagementEnabled() or AppBase::enablePowerManagement(); see PR #867 for more detail.

EXAMPLE

void VisionApp::setup() {
    Cinder::AppNap::PerformActivity("Preprocess images", [this](void) {
        auto handle = std::async([this](void) {
            preprocessImages();
        });
        handle.wait();
    });
}

Long-running operations can use a more explicit form:

void CaptureApp::setup() {
    Cinder::AppNap::BeginActivity("Maintain camera control");
}

void CaptureApp::shutdown() {
    Cinder::AppNap::EndActivity();
}

NOTE

System power assertions can be verified with the pmset command line tool:

$ pmset -g assertions
You can’t perform that action at this time.