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 |