1
2
3
4
5
6 #ifndef CMAJOR_BUILD_FIBER_CONNECTION_INCLUDED
7 #define CMAJOR_BUILD_FIBER_CONNECTION_INCLUDED
8 #include <cmajor/build/Connection.hpp>
9 #include <cmajor/build/Host.hpp>
10
11 namespace cmajor { namespace build {
12
13 class BuildServer;
14
15 class FiberClient : public Host
16 {
17 public:
18 FiberClient();
19 const std::string& Name() const override;
20 void Exit() override;
21 private:
22 std::string name;
23 };
24
25 class FiberServer : public Host
26 {
27 public:
28 FiberServer();
29 const std::string& Name() const override;
30 void Exit() override;
31 private:
32 std::string name;
33 };
34
35 class FiberConnection : public Connection
36 {
37 public:
38 FiberConnection(Log* log);
39 ~FiberConnection();
40 void SetFibers(void* serverFiber, void* clientFiber);
41 void DoSend(JsonObject* messageObject) override;
42 std::unique_ptr<JsonObject> DoReceive() override;
43 void DoClose() override;
44 void Switch();
45 const std::string& GetActor() const override;
46 Host* GetHost() const override;
47 private:
48 std::string messageStr;
49 void* currentFiber;
50 void* serverFiber;
51 void* clientFiber;
52 FiberClient client;
53 FiberServer server;
54 };
55
56 std::unique_ptr<FiberConnection> CreateFiberConnection(Log* log);
57
58 } }
59
60 #endif // CMAJOR_BUILD_SINGLE_SERVER_CONNECTION_INCLUDED