worker-thread.cc 646 Bytes
Newer Older
1
// Copyright 2013 the V8 project authors. All rights reserved.
2 3
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
4

5
#include "src/libplatform/worker-thread.h"
6

7 8
#include "include/v8-platform.h"
#include "src/libplatform/task-queue.h"
9 10

namespace v8 {
11
namespace platform {
12

13
WorkerThread::WorkerThread(TaskQueue* queue)
14
    : Thread(Options("V8 WorkerThread")), queue_(queue) {
15
  CHECK(Start());
16
}
17

18 19
WorkerThread::~WorkerThread() {
  Join();
20 21
}

22
void WorkerThread::Run() {
23
  while (std::unique_ptr<Task> task = queue_->GetNext()) {
24 25
    task->Run();
  }
26 27
}

28 29
}  // namespace platform
}  // namespace v8