Skip to content

Commit 9e48d74

Browse files
committed
update
1 parent bef88af commit 9e48d74

File tree

2 files changed

+34
-3
lines changed

2 files changed

+34
-3
lines changed

src/gossip/gossip.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,6 @@ class GossipServer {
5151
// singleton instance - protected constructor
5252
GossipServer() = default;
5353

54-
explicit GossipServer(const small::server_info::ImmutableInfo& self_info)
55-
: self_info(self_info) {}
56-
5754
// singleton instance - protected destructor
5855
~GossipServer() = default;
5956

@@ -75,6 +72,9 @@ class GossipServer {
7572
// singleton instance - get api
7673
static GossipServer* get_instance();
7774

75+
explicit GossipServer(const small::server_info::ImmutableInfo& self_info)
76+
: self_info(self_info) {}
77+
7878
void broadcast_message(const std::string& message);
7979
};
8080

src/server/server.cc

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,37 @@
7575

7676
namespace small::server {
7777

78+
class Server {
79+
private:
80+
// singleton instance - the only instance
81+
static Server* instance_ptr;
82+
83+
// singleton instance - protected destructor
84+
~Server() = default;
85+
86+
explicit Server(const small::server_info::ImmutableInfo& info)
87+
: info(info) {
88+
this->gossip_server = new small::gossip::GossipServer(info);
89+
}
90+
91+
small::server_info::ImmutableInfo info;
92+
93+
small::gossip::GossipServer* gossip_server;
94+
95+
public:
96+
// singleton instance - assignment-blocker
97+
void operator=(const Server&) = delete;
98+
99+
// singleton instance - copy-blocker
100+
Server(const Server&) = delete;
101+
102+
// singleton instance - init api
103+
static void init_instance(const small::server_info::ImmutableInfo& info);
104+
105+
// singleton instance - get api
106+
static Server* get_instance();
107+
};
108+
78109
std::atomic<bool> stopSignal = false;
79110

80111
class ReaderWriter {

0 commit comments

Comments
 (0)