Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: src/GlobalJsObject.cpp

Issue 29395640: Issue 3595 - Get rid of detached threads for setTimeout (Closed)
Patch Set: address comment Created March 27, 2017, 2:42 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/DefaultTimer.cpp ('k') | src/JsEngine.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/GlobalJsObject.cpp
diff --git a/src/GlobalJsObject.cpp b/src/GlobalJsObject.cpp
index 218ba9accf1050764fa545be1332edc7f7f57862..ed68dac98d6bda5ebf8a7f283e6317283564f7b2 100644
--- a/src/GlobalJsObject.cpp
+++ b/src/GlobalJsObject.cpp
@@ -33,39 +33,17 @@ using namespace AdblockPlus;
namespace
{
- class TimeoutThread : public Thread
- {
- public:
- TimeoutThread(const JsEngine::TimerTask& timerTask)
- : Thread(true), timerTask(timerTask)
- {
- }
-
- void Run()
- {
- Sleep(timerTask.taskInfoIterator->delay);
- if (auto jsEngine = timerTask.weakJsEngine.lock())
- jsEngine->CallTimerTask(timerTask.taskInfoIterator);
- }
-
- private:
- JsEngine::TimerTask timerTask;
- };
-
v8::Handle<v8::Value> SetTimeoutCallback(const v8::Arguments& arguments)
{
- TimeoutThread* timeoutThread;
try
{
- auto jsEngine = AdblockPlus::JsEngine::FromArguments(arguments);
- timeoutThread = new TimeoutThread(jsEngine->CreateTimerTask(arguments));
+ AdblockPlus::JsEngine::ScheduleTimer(arguments);
}
catch (const std::exception& e)
{
v8::Isolate* isolate = arguments.GetIsolate();
return v8::ThrowException(Utils::ToV8String(isolate, e.what()));
}
- timeoutThread->Start();
// We should actually return the timer ID here, which could be
// used via clearTimeout(). But since we don't seem to need
« no previous file with comments | « src/DefaultTimer.cpp ('k') | src/JsEngine.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld