1 // =================================
 2 // Copyright (c) 2021 Seppo Laakko
 3 // Distributed under the MIT license
 4 // =================================
 5 
 6 #ifndef CMAJOR_BUILD_SOCKET_SERVER_INCLUDED
 7 #define CMAJOR_BUILD_SOCKET_SERVER_INCLUDED
 8 #include <cmajor/build/BuildServer.hpp>
 9 #include <cmajor/build/SocketConnection.hpp>
10 #include <cmajor/build/Host.hpp>
11 #include <condition_variable>
12  
13 namespace cmajor { namespace build {
14 
15 class SocketServer public Host
16 {
17 public:
18     SocketServer(Log* log_const std::string& serverNamebool continuous_);
19     const std::string& Name() const override;
20     Log* GetLog() const { return log; }
21     void WaitForRunning();
22     void Run(const std::string& prompt);
23     bool Exiting() const { return exiting; }
24     void Exit() override;
25     void ExitContinuous();
26 private:
27     bool exiting;
28     bool continuous;
29     std::mutex mtx;
30     std::condition_variable running;
31     bool isRunning;
32     Log* log;
33     std::string serverName;
34     std::string name;
35     TcpSocket socket;
36     std::unique_ptr<SocketConnection> connection;
37     std::unique_ptr<BuildServer> buildServer;
38 };
39 
40 } } // namespace cmajor::build
41 
42 #endif // CMAJOR_BUILD_SOCKET_SERVER_INCLUDED