Skip to content

Instantly share code, notes, and snippets.

@mikeabdullah
Created July 29, 2012 17:22
Show Gist options
  • Save mikeabdullah/3200382 to your computer and use it in GitHub Desktop.
Save mikeabdullah/3200382 to your computer and use it in GitHub Desktop.
Power assertion example
// Begin the power assertion
IOPMAssertionID assertionID;
IOReturn asserted = IOPMAssertionCreateWithName(kIOPMAssertionTypeNoIdleSleep,
kIOPMAssertionLevelOn,
CFSTR("Sandvox Publishing"),
&assertionID);
if (asserted != kIOReturnSuccess) // handle the error; log it or something
// Do your long-running work
// End the power assertion
if (asserted == kIOReturnSuccess)
{
asserted = IOPMAssertionRelease(assertionID);
if (asserted != kIOReturnSuccess) // handle the error; log it or something
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment