本文整理汇总了C++中MessageQueue::RemoveAll方法的典型用法代码示例。如果您正苦于以下问题:C++ MessageQueue::RemoveAll方法的具体用法?C++ MessageQueue::RemoveAll怎么用?C++ MessageQueue::RemoveAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MessageQueue
的用法示例。
在下文中一共展示了MessageQueue::RemoveAll方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RunScript
HRESULT RunScript(const char* fileName, LPCWSTR fileContents, BYTE *bcBuffer, char *fullPath)
{
HRESULT hr = S_OK;
MessageQueue * messageQueue = new MessageQueue();
WScriptJsrt::AddMessageQueue(messageQueue);
LPWSTR fullPathWide = nullptr;
IfJsErrorFailLog(ChakraRTInterface::JsSetPromiseContinuationCallback(PromiseContinuationCallback, (void*)messageQueue));
Assert(fileContents != nullptr || bcBuffer != nullptr);
// TODO: Remove this code in a future iteration once Utf8 versions of the Jsrt API is implemented
IfFailGo(Helpers::NarrowStringToWideDynamic(fullPath, &fullPathWide));
JsErrorCode runScript;
if (bcBuffer != nullptr)
{
runScript = ChakraRTInterface::JsRunSerializedScript(fileContents, bcBuffer, WScriptJsrt::GetNextSourceContext(), fullPathWide, nullptr /*result*/);
}
else
{
runScript = ChakraRTInterface::JsRunScript(fileContents, WScriptJsrt::GetNextSourceContext(), fullPathWide, nullptr /*result*/);
}
free(fullPathWide);
if (runScript != JsNoError)
{
WScriptJsrt::PrintException(fileName, runScript);
}
else
{
// Repeatedly flush the message queue until it's empty. It is necessary to loop on this
// because setTimeout can add scripts to execute.
do
{
IfFailGo(messageQueue->ProcessAll(fileName));
} while (!messageQueue->IsEmpty());
}
Error:
if (messageQueue != nullptr)
{
messageQueue->RemoveAll();
delete messageQueue;
}
return hr;
}
示例2: RunScript
//.........这里部分代码省略.........
}
}
}
catch(...)
{
wprintf(_u("Terminal exception in Replay -- exiting.\n"));
ExitProcess(0);
}
#endif
}
else
{
Assert(fileContents != nullptr || bcBuffer != nullptr);
JsErrorCode runScript;
JsValueRef fname;
IfJsErrorFailLog(ChakraRTInterface::JsCreateStringUtf8((const uint8_t*)fullPath,
strlen(fullPath), &fname));
if(bcBuffer != nullptr)
{
runScript = ChakraRTInterface::JsRunSerialized(
bcBuffer,
DummyJsSerializedScriptLoadUtf8Source,
reinterpret_cast<JsSourceContext>(fileContents),
// Use source ptr as sourceContext
fname, nullptr /*result*/);
}
else
{
JsValueRef scriptSource;
IfJsErrorFailLog(ChakraRTInterface::JsCreateExternalArrayBuffer((void*)fileContents,
(unsigned int)strlen(fileContents),
[](void *data)
{
free(data);
}, nullptr, &scriptSource));
#if ENABLE_TTD
if(doTTRecord)
{
ChakraRTInterface::JsTTDStart();
}
runScript = ChakraRTInterface::JsRun(scriptSource,
WScriptJsrt::GetNextSourceContext(), fname,
JsParseScriptAttributeNone, nullptr /*result*/);
if (runScript == JsErrorCategoryUsage)
{
wprintf(_u("FATAL ERROR: Core was compiled without ENABLE_TTD is defined. CH is trying to use TTD interface\n"));
abort();
}
#else
runScript = ChakraRTInterface::JsRun(scriptSource,
WScriptJsrt::GetNextSourceContext(), fname,
JsParseScriptAttributeNone,
nullptr /*result*/);
#endif
}
//Do a yield after the main script body executes
ChakraRTInterface::JsTTDNotifyYield();
if(runScript != JsNoError)
{
WScriptJsrt::PrintException(fileName, runScript);
}
else
{
// Repeatedly flush the message queue until it's empty. It is necessary to loop on this
// because setTimeout can add scripts to execute.
do
{
IfFailGo(messageQueue->ProcessAll(fileName));
} while(!messageQueue->IsEmpty());
}
}
Error:
#if ENABLE_TTD
if(doTTRecord)
{
ChakraRTInterface::JsTTDEmitRecording();
ChakraRTInterface::JsTTDStop();
}
#endif
if (messageQueue != nullptr)
{
messageQueue->RemoveAll();
// clean up possible pinned exception object on exit to avoid potential leak
bool hasException;
if (ChakraRTInterface::JsHasException(&hasException) == JsNoError && hasException)
{
JsValueRef exception = JS_INVALID_REFERENCE;
ChakraRTInterface::JsGetAndClearException(&exception);
}
delete messageQueue;
}
return hr;
}
示例3: RunScript
//.........这里部分代码省略.........
return E_FAIL;
}
ChakraRTInterface::JsTTDStartTimeTravelDebugging();
try
{
INT64 snapEventTime = -1;
INT64 nextEventTime = -2;
while(true)
{
IfJsErrorFailLog(ChakraRTInterface::JsTTDPrepContextsForTopLevelEventMove(chRuntime, nextEventTime, &snapEventTime));
ChakraRTInterface::JsTTDMoveToTopLevelEvent(snapEventTime, nextEventTime);
JsErrorCode res = ChakraRTInterface::JsTTDReplayExecution(&nextEventTime);
//handle any uncaught exception by immediately time-traveling to the throwing line
if(res == JsErrorCategoryScript)
{
wprintf(_u("An unhandled script exception occoured!!!\n"));
ExitProcess(0);
}
if(nextEventTime == -1)
{
wprintf(_u("\nReached end of Execution -- Exiting.\n"));
break;
}
}
}
catch(...)
{
wprintf(_u("Terminal exception in Replay -- exiting."));
ExitProcess(0);
}
#endif
}
else
{
Assert(fileContents != nullptr || bcBuffer != nullptr);
// TODO: Remove this code in a future iteration once Utf8 versions of the Jsrt API is implemented
IfFailGo(Helpers::NarrowStringToWideDynamic(fullPath, &fullPathWide));
JsErrorCode runScript;
if(bcBuffer != nullptr)
{
runScript = ChakraRTInterface::JsRunSerializedScript(fileContents, bcBuffer, WScriptJsrt::GetNextSourceContext(), fullPathWide, nullptr /*result*/);
}
else
{
#if ENABLE_TTD
if(doTTRecord)
{
ChakraRTInterface::JsTTDStartTimeTravelRecording();
}
runScript = ChakraRTInterface::JsTTDRunScript(-1, fileContents, WScriptJsrt::GetNextSourceContext(), fullPathWide, nullptr /*result*/);
#else
runScript = ChakraRTInterface::JsRunScript(fileContents, WScriptJsrt::GetNextSourceContext(), fullPathWide, nullptr /*result*/);
#endif
}
free(fullPathWide);
//Do a yield after the main script body executes
ChakraRTInterface::JsTTDNotifyYield();
if(runScript != JsNoError)
{
WScriptJsrt::PrintException(fileName, runScript);
}
else
{
// Repeatedly flush the message queue until it's empty. It is necessary to loop on this
// because setTimeout can add scripts to execute.
do
{
IfFailGo(messageQueue->ProcessAll(fileName));
} while(!messageQueue->IsEmpty());
}
}
Error:
#if ENABLE_TTD
if(doTTRecord)
{
ChakraRTInterface::JsTTDStopTimeTravelRecording();
}
#endif
if (messageQueue != nullptr)
{
messageQueue->RemoveAll();
delete messageQueue;
}
return hr;
}