v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
operations-barrier.cc
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
#include "
src/tasks/operations-barrier.h
"
6
7
namespace
v8
{
8
namespace
internal
{
9
10
OperationsBarrier::Token
OperationsBarrier::TryLock
() {
11
base::MutexGuard
guard(&
mutex_
);
12
if
(
cancelled_
)
return
{};
13
++
operations_count_
;
14
return
Token
(
this
);
15
}
16
17
void
OperationsBarrier::CancelAndWait
() {
18
base::MutexGuard
guard(&
mutex_
);
19
DCHECK
(!
cancelled_
);
20
cancelled_
=
true
;
21
while
(
operations_count_
> 0) {
22
release_condition_
.
Wait
(&
mutex_
);
23
}
24
}
25
26
void
OperationsBarrier::Release
() {
27
base::MutexGuard
guard(&
mutex_
);
28
if
(--
operations_count_
== 0 &&
cancelled_
) {
29
release_condition_
.
NotifyOne
();
30
}
31
}
32
33
}
// namespace internal
34
}
// namespace v8
v8::base::ConditionVariable::Wait
void Wait(Mutex *mutex)
Definition
condition-variable.cc:27
v8::base::ConditionVariable::NotifyOne
void NotifyOne()
Definition
condition-variable.cc:23
v8::base::LockGuard
Definition
mutex.h:192
v8::internal::OperationsBarrier::Token
Definition
operations-barrier.h:48
v8::internal::OperationsBarrier::cancelled_
bool cancelled_
Definition
operations-barrier.h:109
v8::internal::OperationsBarrier::mutex_
base::Mutex mutex_
Definition
operations-barrier.h:107
v8::internal::OperationsBarrier::Release
void Release()
Definition
operations-barrier.cc:26
v8::internal::OperationsBarrier::CancelAndWait
void CancelAndWait()
Definition
operations-barrier.cc:17
v8::internal::OperationsBarrier::TryLock
Token TryLock()
Definition
operations-barrier.cc:10
v8::internal::OperationsBarrier::operations_count_
size_t operations_count_
Definition
operations-barrier.h:110
v8::internal::OperationsBarrier::release_condition_
base::ConditionVariable release_condition_
Definition
operations-barrier.h:108
v8::internal::internal
internal
Definition
wasm-objects-inl.h:458
v8
Definition
api-arguments-inl.h:19
operations-barrier.h
DCHECK
#define DCHECK(condition)
Definition
logging.h:482
src
tasks
operations-barrier.cc
Generated on Sun Apr 6 2025 21:08:57 for v8 by
1.12.0