本文整理汇总了C++中IOWorkLoop::sleepGate方法的典型用法代码示例。如果您正苦于以下问题:C++ IOWorkLoop::sleepGate方法的具体用法?C++ IOWorkLoop::sleepGate怎么用?C++ IOWorkLoop::sleepGate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IOWorkLoop
的用法示例。
在下文中一共展示了IOWorkLoop::sleepGate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: runAction
IOReturn IOCommandGate::runAction(Action inAction,
void *arg0, void *arg1,
void *arg2, void *arg3)
{
IOWorkLoop * wl;
uintptr_t * sleepersP;
if (!inAction)
return kIOReturnBadArgument;
if (!(wl = workLoop))
return kIOReturnNotReady;
// closeGate is recursive needn't worry if we already hold the lock.
wl->closeGate();
sleepersP = (uintptr_t *) &reserved;
// If the command gate is disabled and we aren't on the workloop thread
// itself then sleep until we get enabled.
IOReturn res;
if (!wl->onThread())
{
while (!enabled)
{
IOReturn sleepResult = kIOReturnSuccess;
if (workLoop)
{
*sleepersP |= kSleepersWaitEnabled;
sleepResult = wl->sleepGate(&enabled, THREAD_ABORTSAFE);
*sleepersP &= ~kSleepersWaitEnabled;
}
bool wakeupTearDown = (!workLoop || (0 != (*sleepersP & kSleepersRemoved)));
if ((kIOReturnSuccess != sleepResult) || wakeupTearDown) {
wl->openGate();
if (wakeupTearDown)
wl->wakeupGate(sleepersP, false); // No further resources used
return kIOReturnAborted;
}
}
}
bool trace = ( gIOKitTrace & kIOTraceCommandGates ) ? true : false;
if (trace) IOTimeStampStartConstant(IODBG_CMDQ(IOCMDQ_ACTION),
VM_KERNEL_UNSLIDE(inAction), (uintptr_t) owner);
IOStatisticsActionCall();
// Must be gated and on the work loop or enabled
*sleepersP += kSleepersActions;
res = (*inAction)(owner, arg0, arg1, arg2, arg3);
*sleepersP -= kSleepersActions;
if (trace) IOTimeStampEndConstant(IODBG_CMDQ(IOCMDQ_ACTION),
VM_KERNEL_UNSLIDE(inAction), (uintptr_t) owner);
if (kSleepersRemoved == ((kSleepersActionsMask|kSleepersRemoved) & *sleepersP))
{
// no actions outstanding
*sleepersP &= ~kSleepersRemoved;
super::setWorkLoop(0);
}
wl->openGate();
return res;
}