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

Side by Side Diff: src/debug-agent.h

Issue 23625003: Cleanup Mutex and related classes. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: REBASE Created 7 years, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/debug.cc ('k') | src/debug-agent.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 30 matching lines...) Expand all
41 41
42 // Debugger agent which starts a socket listener on the debugger port and 42 // Debugger agent which starts a socket listener on the debugger port and
43 // handles connection from a remote debugger. 43 // handles connection from a remote debugger.
44 class DebuggerAgent: public Thread { 44 class DebuggerAgent: public Thread {
45 public: 45 public:
46 DebuggerAgent(const char* name, int port) 46 DebuggerAgent(const char* name, int port)
47 : Thread(name), 47 : Thread(name),
48 isolate_(Isolate::Current()), 48 isolate_(Isolate::Current()),
49 name_(StrDup(name)), port_(port), 49 name_(StrDup(name)), port_(port),
50 server_(OS::CreateSocket()), terminate_(false), 50 server_(OS::CreateSocket()), terminate_(false),
51 session_access_(OS::CreateMutex()), session_(NULL), 51 session_(NULL),
52 terminate_now_(OS::CreateSemaphore(0)), 52 terminate_now_(OS::CreateSemaphore(0)),
53 listening_(OS::CreateSemaphore(0)) { 53 listening_(OS::CreateSemaphore(0)) {
54 ASSERT(isolate_->debugger_agent_instance() == NULL); 54 ASSERT(isolate_->debugger_agent_instance() == NULL);
55 isolate_->set_debugger_agent_instance(this); 55 isolate_->set_debugger_agent_instance(this);
56 } 56 }
57 ~DebuggerAgent() { 57 ~DebuggerAgent() {
58 isolate_->set_debugger_agent_instance(NULL); 58 isolate_->set_debugger_agent_instance(NULL);
59 delete server_; 59 delete server_;
60 } 60 }
61 61
62 void Shutdown(); 62 void Shutdown();
63 void WaitUntilListening(); 63 void WaitUntilListening();
64 64
65 Isolate* isolate() { return isolate_; } 65 Isolate* isolate() { return isolate_; }
66 66
67 private: 67 private:
68 void Run(); 68 void Run();
69 void CreateSession(Socket* socket); 69 void CreateSession(Socket* socket);
70 void DebuggerMessage(const v8::Debug::Message& message); 70 void DebuggerMessage(const v8::Debug::Message& message);
71 void CloseSession(); 71 void CloseSession();
72 void OnSessionClosed(DebuggerAgentSession* session); 72 void OnSessionClosed(DebuggerAgentSession* session);
73 73
74 Isolate* isolate_; 74 Isolate* isolate_;
75 SmartArrayPointer<const char> name_; // Name of the embedding application. 75 SmartArrayPointer<const char> name_; // Name of the embedding application.
76 int port_; // Port to use for the agent. 76 int port_; // Port to use for the agent.
77 Socket* server_; // Server socket for listen/accept. 77 Socket* server_; // Server socket for listen/accept.
78 bool terminate_; // Termination flag. 78 bool terminate_; // Termination flag.
79 Mutex* session_access_; // Mutex guarging access to session_. 79 RecursiveMutex session_access_; // Mutex guarding access to session_.
80 DebuggerAgentSession* session_; // Current active session if any. 80 DebuggerAgentSession* session_; // Current active session if any.
81 Semaphore* terminate_now_; // Semaphore to signal termination. 81 Semaphore* terminate_now_; // Semaphore to signal termination.
82 Semaphore* listening_; 82 Semaphore* listening_;
83 83
84 friend class DebuggerAgentSession; 84 friend class DebuggerAgentSession;
85 friend void DebuggerAgentMessageHandler(const v8::Debug::Message& message); 85 friend void DebuggerAgentMessageHandler(const v8::Debug::Message& message);
86 86
87 DISALLOW_COPY_AND_ASSIGN(DebuggerAgent); 87 DISALLOW_COPY_AND_ASSIGN(DebuggerAgent);
88 }; 88 };
89 89
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 static bool SendMessage(const Socket* conn, 123 static bool SendMessage(const Socket* conn,
124 const v8::Handle<v8::String> message); 124 const v8::Handle<v8::String> message);
125 static int ReceiveAll(const Socket* conn, char* data, int len); 125 static int ReceiveAll(const Socket* conn, char* data, int len);
126 }; 126 };
127 127
128 } } // namespace v8::internal 128 } } // namespace v8::internal
129 129
130 #endif // ENABLE_DEBUGGER_SUPPORT 130 #endif // ENABLE_DEBUGGER_SUPPORT
131 131
132 #endif // V8_DEBUG_AGENT_H_ 132 #endif // V8_DEBUG_AGENT_H_
OLDNEW
« no previous file with comments | « src/debug.cc ('k') | src/debug-agent.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698