v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
locked-queue.h
Go to the documentation of this file.
1
// Copyright 2015 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_UTILS_LOCKED_QUEUE_H_
6
#define V8_UTILS_LOCKED_QUEUE_H_
7
8
#include <atomic>
9
10
#include "
src/base/platform/mutex.h
"
11
#include "
src/base/platform/platform.h
"
12
13
namespace
v8
{
14
namespace
internal
{
15
16
// Simple lock-based unbounded size queue (multi producer; multi consumer) based
17
// on "Simple, Fast, and Practical Non-Blocking and Blocking Concurrent Queue
18
// Algorithms" by M. Scott and M. Michael.
19
// See:
20
// https://www.cs.rochester.edu/research/synchronization/pseudocode/queues.html
21
template
<
typename
Record>
22
class
LockedQueue
final {
23
public
:
24
inline
LockedQueue
();
25
LockedQueue
(
const
LockedQueue
&) =
delete
;
26
LockedQueue
&
operator=
(
const
LockedQueue
&) =
delete
;
27
inline
~LockedQueue
();
28
inline
void
Enqueue
(Record
record
);
29
inline
bool
Dequeue
(Record*
record
);
30
inline
bool
IsEmpty
()
const
;
31
inline
bool
Peek
(Record*
record
)
const
;
32
inline
size_t
size
()
const
;
33
34
private
:
35
struct
Node
;
36
37
mutable
base::Mutex
head_mutex_
;
38
base::Mutex
tail_mutex_
;
39
Node
*
head_
;
40
Node
*
tail_
;
41
std::atomic<size_t>
size_
;
42
};
43
44
}
// namespace internal
45
}
// namespace v8
46
47
#endif
// V8_UTILS_LOCKED_QUEUE_H_
v8::base::Mutex
Definition
mutex.h:36
v8::internal::LockedQueue
Definition
locked-queue.h:22
v8::internal::LockedQueue::IsEmpty
bool IsEmpty() const
Definition
locked-queue-inl.h:76
v8::internal::LockedQueue::tail_mutex_
base::Mutex tail_mutex_
Definition
locked-queue.h:38
v8::internal::LockedQueue::Peek
bool Peek(Record *record) const
Definition
locked-queue-inl.h:82
v8::internal::LockedQueue::size_
std::atomic< size_t > size_
Definition
locked-queue.h:41
v8::internal::LockedQueue::LockedQueue
LockedQueue()
Definition
locked-queue-inl.h:25
v8::internal::LockedQueue::LockedQueue
LockedQueue(const LockedQueue &)=delete
v8::internal::LockedQueue::head_mutex_
base::Mutex head_mutex_
Definition
locked-queue.h:37
v8::internal::LockedQueue::operator=
LockedQueue & operator=(const LockedQueue &)=delete
v8::internal::LockedQueue::size
size_t size() const
Definition
locked-queue-inl.h:91
v8::internal::LockedQueue::head_
Node * head_
Definition
locked-queue.h:39
v8::internal::LockedQueue::tail_
Node * tail_
Definition
locked-queue.h:40
v8::internal::LockedQueue::Enqueue
void Enqueue(Record record)
Definition
locked-queue-inl.h:45
v8::internal::LockedQueue::Dequeue
bool Dequeue(Record *record)
Definition
locked-queue-inl.h:58
v8::internal::LockedQueue::~LockedQueue
~LockedQueue()
Definition
locked-queue-inl.h:33
record
DurationRecord record
Definition
js-temporal-objects.cc:107
mutex.h
v8::internal::internal
internal
Definition
wasm-objects-inl.h:458
v8
Definition
api-arguments-inl.h:19
platform.h
v8::internal::LockedQueue::Node
Definition
locked-queue-inl.h:18
src
utils
locked-queue.h
Generated on Sun Apr 6 2025 21:08:57 for v8 by
1.12.0