Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(203)

Unified Diff: src/futex-emulation.h

Issue 1230303005: Signal a blocked futex if the isolate is interrupted; don't busy-wait (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix windows build Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/futex-emulation.h
diff --git a/src/futex-emulation.h b/src/futex-emulation.h
index 2a07f332d56fc472d3c7fef2028573780ba3bef9..7d93df57b755f24322999f283ceca3da431e1103 100644
--- a/src/futex-emulation.h
+++ b/src/futex-emulation.h
@@ -8,6 +8,7 @@
#include <stdint.h>
#include "src/allocation.h"
+#include "src/base/atomicops.h"
#include "src/base/lazy-instance.h"
#include "src/base/macros.h"
#include "src/base/platform/condition-variable.h"
@@ -39,7 +40,25 @@ class FutexWaitListNode {
next_(nullptr),
backing_store_(nullptr),
wait_addr_(0),
- waiting_(false) {}
+ waiting_(false),
+ interrupted_(false) {}
+
+ bool waiting() { return base::NoBarrier_Load(&waiting_) != 0; }
+ bool interrupted() { return base::NoBarrier_Load(&interrupted_) != 0; }
+
+ void set_waiting(bool value) {
+ base::NoBarrier_Store(&waiting_, value ? 1 : 0);
+ }
+
+ void set_interrupted(bool value) {
+ base::NoBarrier_Store(&interrupted_, value ? 1 : 0);
+ }
+
+ bool CheckInterruptedAndClear() {
+ return base::NoBarrier_CompareAndSwap(&interrupted_, 1, 0) == 1;
+ }
+
+ void NotifyWake();
private:
friend class FutexEmulation;
@@ -50,7 +69,8 @@ class FutexWaitListNode {
FutexWaitListNode* next_;
void* backing_store_;
size_t wait_addr_;
- bool waiting_;
+ base::Atomic32 waiting_;
+ base::Atomic32 interrupted_;
DISALLOW_COPY_AND_ASSIGN(FutexWaitListNode);
};
@@ -114,6 +134,8 @@ class FutexEmulation : public AllStatic {
size_t addr);
private:
+ friend class FutexWaitListNode;
+
static base::LazyMutex mutex_;
static base::LazyInstance<FutexWaitList>::type wait_list_;
};
« no previous file with comments | « src/execution.cc ('k') | src/futex-emulation.cc » ('j') | src/futex-emulation.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698