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


C++ Process::OverlapSemaphore方法代码示例

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


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

示例1: NotifyInterpreterOfCallReturn

// Let the interpreter know that this thread has completed the call, and is ready to finish
// up the external call (clear arguments off the stack of the calling process and push
// on the return value). We have to do this in synchronisation with the main thread since it 
// may involve memory management activities, etc, therefore we signal the Semaphore
// on which the process is waiting, and when the main thread processes this signal it
// will realise that a completion is waiting and send back an appropriate notification
// and then itself wait for the completion to take place on this thread.
void OverlappedCall::NotifyInterpreterOfCallReturn()
{
	m_bCompletionRequestPending = true;
	Process* myProc = GetProcess();
	Interpreter::asynchronousSignal(myProc->OverlapSemaphore());
	//completed = true;
	// We must set this event in case the main thread has quiesced
	Interpreter::SetWakeupEvent();
}
开发者ID:brunobuzzi,项目名称:Dolphin,代码行数:16,代码来源:thrdcall.cpp

示例2: Initiate

bool OverlappedCall::Initiate(CompiledMethod* pMethod, unsigned argCount)
{
	HARDASSERT(::GetCurrentThreadId() == Interpreter::MainThreadId());

	#if TRACING == 1
	{
		TRACELOCK();
		TRACESTREAM << std::hex << GetCurrentThreadId() << L": Initiate; " << *this << std::endl;
	}
	#endif

	// Note that the callDepth member examined by IsInCall() method is only  accessed 
	// from the main thread, or when the main thread is blocked waiting for call 
	// completion on the worker thread, therefore it needs no synchronisation
	if (IsInCall())
		// Nested overlapped calls are not currently supported
		return false;

	m_nCallDepth++;

	// Now save down contextual information
	m_pMethod = pMethod;
	m_nArgCount = argCount;
	ASSERT(m_oteProcess == Interpreter::actualActiveProcessPointer());
	// Copy context from Interpreter
	// ?? Not sure we'll need all this
	m_interpContext = Interpreter::GetRegisters();

	// As we are about to suspend the process, we must also store down the active frame into
	// the suspended frame, and update the active frame with the current IP/SP.
	m_interpContext.PrepareToSuspendProcess();

	Process* proc = m_oteProcess->m_location;

	// Block the process on its own private Semaphore - this simplifies the completion
	// handling since all that is needed is to async signal the Semaphore from the
	// background thread, and then let the process activation code (in process.cpp)
	// spot that an overlapped call completion is pending. However it does create
	// a ref. count issue since the Semaphore may be the only ref. to the process, and
	// the process is probably the only ref. to the Semaphore.
	Interpreter::QueueProcessOn(m_oteProcess, reinterpret_cast<LinkedListOTE*>(proc->OverlapSemaphore()));

	// OK to start the async. operation now
	// We don't use Suspend/Resume because if thread is not suspended yet 
	// (i.e. it hasn't reached its SuspendThread() call), then calling Resume() here
	// will do nothing, and the thread will suspend itself for ever!
	::SetEvent(m_hEvtGo);

	TODO("Try a deliberate SwitchToThread here to see effect of call completing before we reschedule")

	// Reschedule as we probably need another process to run
	if (Interpreter::schedule() == m_oteProcess)
		DebugBreak();

	//CHECKREFERENCES
	return true;
}
开发者ID:brunobuzzi,项目名称:Dolphin,代码行数:57,代码来源:thrdcall.cpp


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