summaryrefslogtreecommitdiff
path: root/deps/v8/src/futex-emulation.h
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/futex-emulation.h')
-rw-r--r--deps/v8/src/futex-emulation.h33
1 files changed, 33 insertions, 0 deletions
diff --git a/deps/v8/src/futex-emulation.h b/deps/v8/src/futex-emulation.h
index 801198fab8..a1580099d6 100644
--- a/deps/v8/src/futex-emulation.h
+++ b/deps/v8/src/futex-emulation.h
@@ -35,6 +35,18 @@ class Handle;
class Isolate;
class JSArrayBuffer;
+class AtomicsWaitWakeHandle {
+ public:
+ explicit AtomicsWaitWakeHandle(Isolate* isolate) : isolate_(isolate) {}
+
+ void Wake();
+ inline bool has_stopped() const { return stopped_; }
+
+ private:
+ Isolate* isolate_;
+ bool stopped_ = false;
+};
+
class FutexWaitListNode {
public:
FutexWaitListNode()
@@ -50,12 +62,17 @@ class FutexWaitListNode {
private:
friend class FutexEmulation;
friend class FutexWaitList;
+ friend class ResetWaitingOnScopeExit;
base::ConditionVariable cond_;
+ // prev_ and next_ are protected by FutexEmulation::mutex_.
FutexWaitListNode* prev_;
FutexWaitListNode* next_;
void* backing_store_;
size_t wait_addr_;
+ // waiting_ and interrupted_ are protected by FutexEmulation::mutex_
+ // if this node is currently contained in FutexEmulation::wait_list_
+ // or an AtomicsWaitWakeHandle has access to it.
bool waiting_;
bool interrupted_;
@@ -79,6 +96,16 @@ class FutexWaitList {
DISALLOW_COPY_AND_ASSIGN(FutexWaitList);
};
+class ResetWaitingOnScopeExit {
+ public:
+ explicit ResetWaitingOnScopeExit(FutexWaitListNode* node) : node_(node) {}
+ ~ResetWaitingOnScopeExit() { node_->waiting_ = false; }
+
+ private:
+ FutexWaitListNode* node_;
+
+ DISALLOW_COPY_AND_ASSIGN(ResetWaitingOnScopeExit);
+};
class FutexEmulation : public AllStatic {
public:
@@ -109,7 +136,13 @@ class FutexEmulation : public AllStatic {
private:
friend class FutexWaitListNode;
+ friend class AtomicsWaitWakeHandle;
+ // `mutex_` protects the composition of `wait_list_` (i.e. no elements may be
+ // added or removed without holding this mutex), as well as the `waiting_`
+ // and `interrupted_` fields for each individual list node that is currently
+ // part of the list. It must be the mutex used together with the `cond_`
+ // condition variable of such nodes.
static base::LazyMutex mutex_;
static base::LazyInstance<FutexWaitList>::type wait_list_;
};