Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(745)

Unified Diff: test/inspector-protocol/task-runner.cc

Issue 2358943002: [inspector] added inspector protocol test runner (Closed)
Patch Set: a Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: test/inspector-protocol/task-runner.cc
diff --git a/test/inspector-protocol/task-runner.cc b/test/inspector-protocol/task-runner.cc
new file mode 100644
index 0000000000000000000000000000000000000000..040694036f716121ba5843a32bc44ba603f9ac2a
--- /dev/null
+++ b/test/inspector-protocol/task-runner.cc
@@ -0,0 +1,42 @@
+// Copyright 2016 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "test/inspector-protocol/task-runner.h"
+
+#include "test/inspector-protocol/task-queue.h"
+#include "test/inspector-protocol/task.h"
+
+namespace v8_inspector {
+
+TaskRunner::TaskRunner(TaskQueue* queue)
+ : Thread(Options("Task Runner")),
+ queue_(queue),
+ state_(TaskRunner::kRunning),
+ isolate_(NULL) {
+ Start();
+}
+
+TaskRunner::~TaskRunner() { Join(); }
+
+void TaskRunner::SetContext(v8::Local<v8::Context> context) {
+ isolate_ = context->GetIsolate();
+ context_.Reset(isolate_, context);
+}
+
+void TaskRunner::Run() {
+ while (true) {
+ Task* task = queue_->GetNext(false);
+ if (!task) return;
+ if (isolate_)
+ task->Run(isolate_, context_);
+ else
+ task->Run();
+ delete task;
+ if (state_.Value() == kStopRequested) return;
+ }
+}
+
+void TaskRunner::Stop() { state_.SetValue(kStopRequested); }
+
+} // v8_inspector

Powered by Google App Engine
This is Rietveld 408576698