move shell to separate thread
This commit is contained in:
+14
-13
@@ -6,27 +6,28 @@
|
||||
#include <event2/event.h>
|
||||
|
||||
#include "ProxyServer.hh"
|
||||
#include "Shell.hh"
|
||||
#include "ServerState.hh"
|
||||
|
||||
#define SHELL_PROMPT "newserv> "
|
||||
|
||||
class ServerShell : public Shell {
|
||||
class ServerShell : public std::enable_shared_from_this<ServerShell> {
|
||||
public:
|
||||
ServerShell(
|
||||
std::shared_ptr<struct event_base> base,
|
||||
std::shared_ptr<ServerState> state);
|
||||
virtual ~ServerShell() = default;
|
||||
class exit_shell : public std::runtime_error {
|
||||
public:
|
||||
exit_shell();
|
||||
~exit_shell() = default;
|
||||
};
|
||||
|
||||
explicit ServerShell(std::shared_ptr<ServerState> state);
|
||||
ServerShell(const ServerShell&) = delete;
|
||||
ServerShell(ServerShell&&) = delete;
|
||||
ServerShell& operator=(const ServerShell&) = delete;
|
||||
ServerShell& operator=(ServerShell&&) = delete;
|
||||
~ServerShell();
|
||||
|
||||
std::shared_ptr<ProxyServer::LinkedSession> get_proxy_session(const std::string& name);
|
||||
|
||||
protected:
|
||||
std::shared_ptr<ServerState> state;
|
||||
std::thread th;
|
||||
|
||||
std::shared_ptr<ProxyServer::LinkedSession> get_proxy_session(
|
||||
const std::string& name);
|
||||
|
||||
virtual void print_prompt();
|
||||
virtual void execute_command(const std::string& command);
|
||||
void thread_fn();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user