• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "src/libplatform/worker-thread.h"
6 
7 #include "include/v8-platform.h"
8 #include "src/libplatform/task-queue.h"
9 
10 namespace v8 {
11 namespace platform {
12 
WorkerThread(TaskQueue * queue)13 WorkerThread::WorkerThread(TaskQueue* queue)
14     : Thread(Options("V8 WorkerThread")), queue_(queue) {
15   CHECK(Start());
16 }
17 
~WorkerThread()18 WorkerThread::~WorkerThread() {
19   Join();
20 }
21 
Run()22 void WorkerThread::Run() {
23   while (std::unique_ptr<Task> task = queue_->GetNext()) {
24     task->Run();
25   }
26 }
27 
28 }  // namespace platform
29 }  // namespace v8
30