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

Unified Diff: src/v8threads.h

Issue 6685088: Merge isolates to bleeding_edge. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 years, 9 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 | « src/v8globals.h ('k') | src/v8threads.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/v8threads.h
===================================================================
--- src/v8threads.h (revision 7267)
+++ src/v8threads.h (working copy)
@@ -34,8 +34,6 @@
class ThreadState {
public:
- // Iterate over in-use states.
- static ThreadState* FirstInUse();
// Returns NULL after the last one.
ThreadState* Next();
@@ -44,8 +42,6 @@
void LinkInto(List list);
void Unlink();
- static ThreadState* GetFree();
-
// Id of thread.
void set_id(int id) { id_ = id; }
int id() { return id_; }
@@ -59,7 +55,7 @@
// Get data area for archiving a thread.
char* data() { return data_; }
private:
- ThreadState();
+ explicit ThreadState(ThreadManager* thread_manager);
void AllocateSpace();
@@ -69,13 +65,9 @@
ThreadState* next_;
ThreadState* previous_;
- // In the following two lists there is always at least one object on the list.
- // The first object is a flying anchor that is only there to simplify linking
- // and unlinking.
- // Head of linked list of free states.
- static ThreadState* free_anchor_;
- // Head of linked list of states in use.
- static ThreadState* in_use_anchor_;
+ ThreadManager* thread_manager_;
+
+ friend class ThreadManager;
};
@@ -93,35 +85,52 @@
};
-class ThreadManager : public AllStatic {
+class ThreadManager {
public:
- static void Lock();
- static void Unlock();
+ void Lock();
+ void Unlock();
- static void ArchiveThread();
- static bool RestoreThread();
- static void FreeThreadResources();
- static bool IsArchived();
+ void ArchiveThread();
+ bool RestoreThread();
+ void FreeThreadResources();
+ bool IsArchived();
- static void Iterate(ObjectVisitor* v);
- static void IterateArchivedThreads(ThreadVisitor* v);
- static bool IsLockedByCurrentThread() { return mutex_owner_.IsSelf(); }
+ void Iterate(ObjectVisitor* v);
+ void IterateArchivedThreads(ThreadVisitor* v);
+ bool IsLockedByCurrentThread() { return mutex_owner_.IsSelf(); }
- static int CurrentId();
- static void AssignId();
- static bool HasId();
+ int CurrentId();
- static void TerminateExecution(int thread_id);
+ void TerminateExecution(int thread_id);
+ // Iterate over in-use states.
+ ThreadState* FirstThreadStateInUse();
+ ThreadState* GetFreeThreadState();
+
static const int kInvalidId = -1;
private:
- static void EagerlyArchiveThread();
+ ThreadManager();
+ ~ThreadManager();
- static int last_id_; // V8 threads are identified through an integer.
- static Mutex* mutex_;
- static ThreadHandle mutex_owner_;
- static ThreadHandle lazily_archived_thread_;
- static ThreadState* lazily_archived_thread_state_;
+ void EagerlyArchiveThread();
+
+ Mutex* mutex_;
+ ThreadHandle mutex_owner_;
+ ThreadHandle lazily_archived_thread_;
+ ThreadState* lazily_archived_thread_state_;
+
+ // In the following two lists there is always at least one object on the list.
+ // The first object is a flying anchor that is only there to simplify linking
+ // and unlinking.
+ // Head of linked list of free states.
+ ThreadState* free_anchor_;
+ // Head of linked list of states in use.
+ ThreadState* in_use_anchor_;
+
+ Isolate* isolate_;
+
+ friend class Isolate;
+ friend class ThreadState;
};
@@ -142,14 +151,12 @@
static void PreemptionReceived();
private:
- explicit ContextSwitcher(int every_n_ms);
+ explicit ContextSwitcher(Isolate* isolate, int every_n_ms);
void Run();
bool keep_going_;
int sleep_ms_;
-
- static ContextSwitcher* singleton_;
};
} } // namespace v8::internal
« no previous file with comments | « src/v8globals.h ('k') | src/v8threads.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698