Re: Correct use of IOPMAssertionCreateWithName(...)
Re: Correct use of IOPMAssertionCreateWithName(...)
- Subject: Re: Correct use of IOPMAssertionCreateWithName(...)
- From: Jean-Daniel Dupas <email@hidden>
- Date: Tue, 9 Mar 2010 11:50:22 +0100
Le 9 mars 2010 à 06:39, James Bucanek a écrit : Greetings,
I'm not sure that Darwin-Dev is the right place to post this, but since this is essentially an IOKit question, it's the closest I could find to the topic.
I'm upgrading my app and would like to use IOPMAssertionCreate()/IOPMAssertionCreateWithName() to prohibit the computer from going to sleep while performing a backup. However, the documentation seems a little vague, which has left me wondering exactly how these functions should be used.
Do I:
(a) Call IOPMAssertionCreateWithName() when starting an action that should not be interrupted by sleep mode and then call IOPMAssertionRelease() when that's over.
Or (b) do I call IOPMAssertionCreateWithName() with kIOPMAssertionLevelOn when the action starts, immediately call IOPMAssertionRelease() to release the assertion_id, and then later call IOPMAssertionCreateWithName() with kIOPMAssertionLevelOff when the task is complete.
Or (c) ?
I guess my question is really "what sequence of calls establish and rescind the sleep mode prohibition?" I skimmed the IOKit documentation and didn't find anything illuminating. I couldn't find any example code that employed these calls.
TIA,
James
a)
Listing 2
IOPMAssertionID assertionID;
IOReturn success = IOPMAssertionCreate(kIOPMAssertionTypeNoDisplaySleep,
kIOPMAssertionLevelOn, &assertionID);
if (success == kIOReturnSuccess)
{
//Add the work you need to do without
// the system sleeping here.
success = IOPMAssertionRelease(assertionID);
//The system will be able to sleep again.
}
...
|
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden