summaryrefslogtreecommitdiff
path: root/chromium/v8/src/libplatform/worker-thread.cc
blob: a565854751062961ff9f778819684b0106fb8b8d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// Copyright 2013 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 "src/libplatform/worker-thread.h"

#include "include/v8-platform.h"
#include "src/libplatform/task-queue.h"

namespace v8 {
namespace platform {

WorkerThread::WorkerThread(TaskQueue* queue)
    : Thread(Options("V8 WorkerThread")), queue_(queue) {
  CHECK(Start());
}

WorkerThread::~WorkerThread() {
  Join();
}

void WorkerThread::Run() {
  while (std::unique_ptr<Task> task = queue_->GetNext()) {
    task->Run();
  }
}

}  // namespace platform
}  // namespace v8