本文整理汇总了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();
}
示例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;
}