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

Unified Diff: src/v8threads.h

Issue 503022: Add locker support to DebugMessageDispatchHandler (Closed)
Patch Set: make compilable with debugger support off Created 11 years 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/debug.cc ('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
diff --git a/src/v8threads.h b/src/v8threads.h
index 06840532812ee9133e1d8160a14492e64d9d04db..9fa6f0eaf91f8ec3e61914e5b5926e0fda077dea 100644
--- a/src/v8threads.h
+++ b/src/v8threads.h
@@ -29,6 +29,11 @@
#define V8_V8THREADS_H_
namespace v8 {
+
+struct LockParameters {
+ bool successfully_relaied;
+};
+
namespace internal {
@@ -78,12 +83,43 @@ class ThreadState {
static ThreadState* in_use_anchor_;
};
+#ifdef ENABLE_DEBUGGER_SUPPORT
+
+struct Promises {
+ bool promise_to_process_debug_commands;
+ void Reset() {
+ promise_to_process_debug_commands = false;
+ }
+};
+
+// This mutex has an additional feature: you may try acquire it if it's free or
+// ASK someone who owns it right now to do a particular chore for you before
+// releasing it. The current owner is guaranteed to NOTICE your ask.
+class MutexWithResponsibilities {
+ public:
+ MutexWithResponsibilities();
+ ~MutexWithResponsibilities();
+ void Lock();
+ bool LockOrAsk(bool Promises::* promise);
+ void Unlock();
+
+ private:
+ Mutex* flag_mutex_;
+ Semaphore* sem_;
+ bool locked_;
+ bool has_promises_;
+ Promises promises_;
+};
+#endif
class ThreadManager : public AllStatic {
public:
static void Lock();
static void Unlock();
+#ifdef ENABLE_DEBUGGER_SUPPORT
+ static bool LockOrAsk(bool Promises::* promise);
+#endif
static void ArchiveThread();
static bool RestoreThread();
static void FreeThreadResources();
@@ -105,7 +141,11 @@ class ThreadManager : public AllStatic {
static void EagerlyArchiveThread();
static int last_id_; // V8 threads are identified through an integer.
+#ifdef ENABLE_DEBUGGER_SUPPORT
+ static MutexWithResponsibilities* mutex_;
+#else
static Mutex* mutex_;
+#endif
static ThreadHandle mutex_owner_;
static ThreadHandle lazily_archived_thread_;
static ThreadState* lazily_archived_thread_state_;
« no previous file with comments | « src/debug.cc ('k') | src/v8threads.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698