v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
task-queue.cc
Go to the documentation of this file.
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
6
8#include "src/base/logging.h"
11
12namespace v8 {
13namespace platform {
14
15TaskQueue::TaskQueue() : process_queue_semaphore_(0), terminated_(false) {}
16
17
23
24void TaskQueue::Append(std::unique_ptr<Task> task) {
25 base::MutexGuard guard(&lock_);
27 task_queue_.push(std::move(task));
29}
30
31std::unique_ptr<Task> TaskQueue::GetNext() {
32 for (;;) {
33 {
34 base::MutexGuard guard(&lock_);
35 if (!task_queue_.empty()) {
36 std::unique_ptr<Task> result = std::move(task_queue_.front());
37 task_queue_.pop();
38 return result;
39 }
40 if (terminated_) {
42 return nullptr;
43 }
44 }
46 }
47}
48
49
56
58 for (;;) {
59 {
60 base::MutexGuard guard(&lock_);
61 if (task_queue_.empty()) return;
62 }
64 }
65}
66
67} // namespace platform
68} // namespace v8
static void Sleep(TimeDelta interval)
static constexpr TimeDelta FromMilliseconds(int64_t milliseconds)
Definition time.h:84
std::unique_ptr< Task > GetNext()
Definition task-queue.cc:31
std::queue< std::unique_ptr< Task > > task_queue_
Definition task-queue.h:47
void Append(std::unique_ptr< Task > task)
Definition task-queue.cc:24
void BlockUntilQueueEmptyForTesting()
Definition task-queue.cc:57
base::Semaphore process_queue_semaphore_
Definition task-queue.h:45
ZoneVector< RpoNumber > & result
#define DCHECK(condition)
Definition logging.h:482