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

Unified Diff: src/JsEngine.cpp

Issue 29370568: Issue #4692 - Move responsibility for engine reference from tasks to scheduler
Patch Set: Created Dec. 31, 2016, 10:37 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/FileSystemJsObject.cpp ('k') | src/JsEngineInternal.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/JsEngine.cpp
===================================================================
--- a/src/JsEngine.cpp
+++ b/src/JsEngine.cpp
@@ -22,18 +22,10 @@
#include "JsEngineInternal.h"
#include "JsEngineTransition.h"
#include "JsError.h"
-#include "Scheduler.h"
#include "Utils.h"
#include "WebRequestJsObject.h"
-const AdblockPlus::ImmediateSingleUseThreadType AdblockPlus::ImmediateSingleUseThread = {};
-
-class AdblockPlus::JsEngine::SchedulerImpl
- : public SchedulerT<SingleUseWorker>
-{
-public:
- SchedulerImpl() {} // = default;
-};
+const ImmediateSingleUseThreadType ImmediateSingleUseThread = {};
namespace
{
@@ -98,8 +90,7 @@
}
AdblockPlus::JsEngine::JsEngine(const ScopedV8IsolatePtr& isolate)
- : isolate(isolate),
- scheduler(new SchedulerImpl()) // TODO: make_unique once available
+ : isolate(isolate)
{}
JsEngineInternal::JsEngineInternal(const AdblockPlus::ScopedV8IsolatePtr& isolate)
@@ -117,14 +108,14 @@
auto auxiliaryObject = v8::Object::New();
auxiliaryObject->Set(ToV8String("GET"), MakeCallback(::GETCallback));
globalObject->Set(ToV8String("_webRequest"), auxiliaryObject);
- // File system I/O
- auxiliaryObject = v8::Object::New();
- auxiliaryObject->Set(ToV8String("read"), MakeCallback(::ReadCallback));
- auxiliaryObject->Set(ToV8String("write"), MakeCallback(::WriteCallback));
- auxiliaryObject->Set(ToV8String("move"), MakeCallback(::MoveCallback));
- auxiliaryObject->Set(ToV8String("remove"), MakeCallback(::RemoveCallback));
- auxiliaryObject->Set(ToV8String("stat"), MakeCallback(::StatCallback));
- auxiliaryObject->Set(ToV8String("resolve"), MakeCallback(::ResolveCallback));
+ // File system I/O
+ auxiliaryObject = v8::Object::New();
+ auxiliaryObject->Set(ToV8String("read"), MakeCallback(::ReadCallback));
+ auxiliaryObject->Set(ToV8String("write"), MakeCallback(::WriteCallback));
+ auxiliaryObject->Set(ToV8String("move"), MakeCallback(::MoveCallback));
+ auxiliaryObject->Set(ToV8String("remove"), MakeCallback(::RemoveCallback));
+ auxiliaryObject->Set(ToV8String("stat"), MakeCallback(::StatCallback));
+ auxiliaryObject->Set(ToV8String("resolve"), MakeCallback(::ResolveCallback));
globalObject->Set(ToV8String("_fileSystem"), auxiliaryObject);
// TODO: Move the rest of the global object initializations here
@@ -382,17 +373,16 @@
global->SetProperty(name, value);
}
-void AdblockPlus::JsEngine::Schedule(std::function<void()> task,
- AdblockPlus::ImmediateSingleUseThreadType)
+void JsEngineInternal::ScheduleTaskInternal(std::shared_ptr<TaskFunctionInterface>&& body)
{
// The present version of the scheduler only does immediate and single-use
// It does not, however, detach threads like the legacy thread behavior did.
- scheduler->Run(task);
+ scheduler.Run(Task(this, std::move(body)));
}
-void AdblockPlus::JsEngine::WaitForQuietScheduler()
+void JsEngineInternal::WaitForQuietScheduler()
{
- scheduler->JoinAll();
+ scheduler.JoinAll();
}
JsEngineInternal* ToInternal(AdblockPlus::JsEnginePtr p)
« no previous file with comments | « src/FileSystemJsObject.cpp ('k') | src/JsEngineInternal.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld