1 #ifndef RBX_CONSOLE_HPP
2 #define RBX_CONSOLE_HPP
4 #include "machine_thread.hpp"
5 #include "spinlock.hpp"
24 class Listener
: public MachineThread
{
33 Listener(STATE
, Console
* console
);
36 bool connection_initiated();
38 void start_thread(STATE
);
39 void initialize(STATE
);
43 void trace_objects(STATE
, std::function
<void (STATE
, Object
**)> f
);
46 typedef std::list
<char*> RequestList
;
48 class Response
: public MachineThread
{
56 RequestList
* request_list_
;
58 locks::spinlock_mutex list_lock_
;
60 std::mutex response_lock_
;
61 std::condition_variable response_cond_
;
65 Response(STATE
, Console
* console
);
68 void initialize(STATE
);
69 void start_thread(STATE
);
72 void stop_thread(STATE
);
73 void after_fork_child(STATE
);
75 void close_response();
76 void clear_requests();
78 void send_request(STATE
, const char* request
);
79 void write_response(STATE
, const char* response
, intptr_t size
);
81 void trace_objects(STATE
, std::function
<void (STATE
, Object
**)> f
);
84 class Request
: public MachineThread
{
96 Request(STATE
, Console
* console
, Response
* response
);
102 void initialize(STATE
);
103 void start_thread(STATE
);
106 void stop_thread(STATE
);
107 void after_fork_child(STATE
);
109 void close_request();
111 char* read_request(STATE
);
113 void trace_objects(STATE
, std::function
<void (STATE
, Object
**)> f
);
117 using namespace console
;
120 std::string console_path_
;
121 std::string request_path_
;
122 std::string response_path_
;
128 Object
* ruby_console_
;
134 Object
* ruby_console() {
135 return ruby_console_
;
138 std::string
& console_path() {
139 return console_path_
;
142 std::string
& request_path() {
143 return request_path_
;
146 std::string
& response_path() {
147 return response_path_
;
156 void after_fork_child(STATE
);
159 Class
* server_class(STATE
);
161 void trace_objects(STATE
, std::function
<void (STATE
, Object
**)> f
);