v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
task-queue.h
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
5
#ifndef V8_LIBPLATFORM_TASK_QUEUE_H_
6
#define V8_LIBPLATFORM_TASK_QUEUE_H_
7
8
#include <memory>
9
#include <queue>
10
11
#include "
include/libplatform/libplatform-export.h
"
12
#include "
src/base/platform/mutex.h
"
13
#include "
src/base/platform/semaphore.h
"
14
#include "testing/gtest/include/gtest/gtest_prod.h"
// nogncheck
15
16
namespace
v8
{
17
18
class
Task
;
19
20
namespace
platform {
21
22
class
V8_PLATFORM_EXPORT
TaskQueue
{
23
public
:
24
TaskQueue
();
25
~TaskQueue
();
26
27
TaskQueue
(
const
TaskQueue
&) =
delete
;
28
TaskQueue
&
operator=
(
const
TaskQueue
&) =
delete
;
29
30
// Appends a task to the queue. The queue takes ownership of |task|.
31
void
Append(std::unique_ptr<Task> task);
32
33
// Returns the next task to process. Blocks if no task is available. Returns
34
// nullptr if the queue is terminated.
35
std::unique_ptr<Task> GetNext();
36
37
// Terminate the queue.
38
void
Terminate();
39
40
private
:
41
FRIEND_TEST
(WorkerThreadTest, PostSingleTask);
42
43
void
BlockUntilQueueEmptyForTesting();
44
45
base::Semaphore
process_queue_semaphore_
;
46
base::Mutex
lock_
;
47
std::queue<std::unique_ptr<Task>>
task_queue_
;
48
bool
terminated_
;
49
};
50
51
}
// namespace platform
52
}
// namespace v8
53
54
55
#endif
// V8_LIBPLATFORM_TASK_QUEUE_H_
v8::base::Mutex
Definition
mutex.h:36
v8::base::Semaphore
Definition
semaphore.h:41
v8::platform::TaskQueue
Definition
task-queue.h:22
v8::platform::TaskQueue::task_queue_
std::queue< std::unique_ptr< Task > > task_queue_
Definition
task-queue.h:47
v8::platform::TaskQueue::terminated_
bool terminated_
Definition
task-queue.h:48
v8::platform::TaskQueue::lock_
base::Mutex lock_
Definition
task-queue.h:46
v8::platform::TaskQueue::operator=
TaskQueue & operator=(const TaskQueue &)=delete
v8::platform::TaskQueue::TaskQueue
TaskQueue(const TaskQueue &)=delete
v8::platform::TaskQueue::process_queue_semaphore_
base::Semaphore process_queue_semaphore_
Definition
task-queue.h:45
v8::platform::TaskQueue::FRIEND_TEST
FRIEND_TEST(WorkerThreadTest, PostSingleTask)
libplatform-export.h
V8_PLATFORM_EXPORT
#define V8_PLATFORM_EXPORT
Definition
libplatform-export.h:24
mutex.h
cppgc::Task
v8::Task Task
Definition
platform.h:23
v8
Definition
api-arguments-inl.h:19
semaphore.h
src
libplatform
task-queue.h
Generated on Sun Apr 6 2025 21:08:54 for v8 by
1.12.0