当前位置: 首页>>代码示例>>C++>>正文


C++ IOWorkLoop::onThread方法代码示例

本文整理汇总了C++中IOWorkLoop::onThread方法的典型用法代码示例。如果您正苦于以下问题:C++ IOWorkLoop::onThread方法的具体用法?C++ IOWorkLoop::onThread怎么用?C++ IOWorkLoop::onThread使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IOWorkLoop的用法示例。


在下文中一共展示了IOWorkLoop::onThread方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: attemptAction

IOReturn IOCommandGate::attemptAction(Action inAction,
                                      void *arg0, void *arg1,
                                      void *arg2, void *arg3)
{
    IOReturn res;
    IOWorkLoop * wl;

    if (!inAction)
        return kIOReturnBadArgument;
    if (!(wl = workLoop))
        return kIOReturnNotReady;

    // Try to close the gate if can't get return immediately.
    if (!wl->tryCloseGate())
        return kIOReturnCannotLock;

    // If the command gate is disabled then sleep until we get a wakeup
    if (!wl->onThread() && !enabled)
        res = kIOReturnNotPermitted;
    else {
		
        bool trace = ( gIOKitTrace & kIOTraceCommandGates ) ? true : false;
		
        if (trace)
            IOTimeStampStartConstant(IODBG_CMDQ(IOCMDQ_ACTION),
				     VM_KERNEL_UNSLIDE(inAction), (uintptr_t) owner);
        
        IOStatisticsActionCall();
        
        res = (*inAction)(owner, arg0, arg1, arg2, arg3);
		
        if (trace)
            IOTimeStampEndConstant(IODBG_CMDQ(IOCMDQ_ACTION),
				   VM_KERNEL_UNSLIDE(inAction), (uintptr_t) owner);
    }

    wl->openGate();

    return res;
}
开发者ID:JackieXie168,项目名称:xnu,代码行数:40,代码来源:IOCommandGate.cpp

示例2: 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;
}
开发者ID:JackieXie168,项目名称:xnu,代码行数:69,代码来源:IOCommandGate.cpp


注:本文中的IOWorkLoop::onThread方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。