v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
parallel-work-item.h
Go to the documentation of this file.
1
// Copyright 2020 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_HEAP_PARALLEL_WORK_ITEM_H_
6
#define V8_HEAP_PARALLEL_WORK_ITEM_H_
7
8
#include <atomic>
9
10
namespace
v8
{
11
namespace
internal
{
12
13
class
ParallelWorkItem
{
14
public
:
15
ParallelWorkItem
() =
default
;
16
17
bool
TryAcquire
() {
18
// memory_order_relaxed is sufficient as the work item's state itself hasn't
19
// been modified since the beginning of its associated job. This is only
20
// atomically acquiring the right to work on it.
21
return
reinterpret_cast<
std::atomic<bool>*
>
(&
acquire_
)->exchange(
22
true
, std::memory_order_relaxed) ==
false
;
23
}
24
25
bool
IsAcquired
()
const
{
26
return
reinterpret_cast<
const
std::atomic<bool>*
>
(&
acquire_
)->load(
27
std::memory_order_relaxed);
28
}
29
30
private
:
31
bool
acquire_
{
false
};
32
};
33
34
}
// namespace internal
35
}
// namespace v8
36
37
#endif
// V8_HEAP_PARALLEL_WORK_ITEM_H_
v8::internal::ParallelWorkItem
Definition
parallel-work-item.h:13
v8::internal::ParallelWorkItem::IsAcquired
bool IsAcquired() const
Definition
parallel-work-item.h:25
v8::internal::ParallelWorkItem::acquire_
bool acquire_
Definition
parallel-work-item.h:31
v8::internal::ParallelWorkItem::ParallelWorkItem
ParallelWorkItem()=default
v8::internal::ParallelWorkItem::TryAcquire
bool TryAcquire()
Definition
parallel-work-item.h:17
v8::internal::internal
internal
Definition
wasm-objects-inl.h:458
v8
Definition
api-arguments-inl.h:19
src
heap
parallel-work-item.h
Generated on Sun Apr 6 2025 21:08:54 for v8 by
1.12.0