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

Unified Diff: src/isolate.h

Issue 637263002: Fix data races and leaks related to v8::Lockers (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 2 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
« no previous file with comments | « include/v8.h ('k') | src/v8threads.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/isolate.h
diff --git a/src/isolate.h b/src/isolate.h
index a12216aefdf82f7c7995159412ff141a8365f7b9..a94678d135fe857e47f7a465ef1c6bd7686b410f 100644
--- a/src/isolate.h
+++ b/src/isolate.h
@@ -179,7 +179,12 @@ typedef ZoneList<Handle<Object> > ZoneObjectList;
class ThreadId {
public:
// Creates an invalid ThreadId.
- ThreadId() : id_(kInvalidId) {}
+ ThreadId() { base::NoBarrier_Store(&id_, kInvalidId); }
+
+ ThreadId& operator=(const ThreadId& other) {
+ base::NoBarrier_Store(&id_, base::NoBarrier_Load(&other.id_));
+ return *this;
+ }
// Returns ThreadId for current thread.
static ThreadId Current() { return ThreadId(GetCurrentThreadId()); }
@@ -189,17 +194,17 @@ class ThreadId {
// Compares ThreadIds for equality.
INLINE(bool Equals(const ThreadId& other) const) {
- return id_ == other.id_;
+ return base::NoBarrier_Load(&id_) == base::NoBarrier_Load(&other.id_);
}
// Checks whether this ThreadId refers to any thread.
INLINE(bool IsValid() const) {
- return id_ != kInvalidId;
+ return base::NoBarrier_Load(&id_) != kInvalidId;
}
// Converts ThreadId to an integer representation
// (required for public API: V8::V8::GetCurrentThreadId).
- int ToInteger() const { return id_; }
+ int ToInteger() const { return static_cast<int>(base::NoBarrier_Load(&id_)); }
// Converts ThreadId to an integer representation
// (required for public API: V8::V8::TerminateExecution).
@@ -208,13 +213,13 @@ class ThreadId {
private:
static const int kInvalidId = -1;
- explicit ThreadId(int id) : id_(id) {}
+ explicit ThreadId(int id) { base::NoBarrier_Store(&id_, id); }
static int AllocateThreadId();
static int GetCurrentThreadId();
- int id_;
+ base::Atomic32 id_;
static base::Atomic32 highest_thread_id_;
« no previous file with comments | « include/v8.h ('k') | src/v8threads.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698