Skip to content

Commit 79af226

Browse files
committed
update
1 parent 1e4dbaa commit 79af226

File tree

9 files changed

+48
-29
lines changed

9 files changed

+48
-29
lines changed

.vscode/settings.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
11
{
22
"C_Cpp.default.compileCommands": "${workspaceFolder}/build/debug/compile_commands.json",
3-
"cmake.configureArgs": [
4-
"--fresh"
5-
],
63
}

play/lib_a.cc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#include <iostream>
2+
3+
#include "lib_b.h"
4+
5+
namespace lib_a {
6+
void lib_a_function() {
7+
std::cout << "lib_a_function called" << std::endl;
8+
lib_b::lib_b_self();
9+
}
10+
11+
void lib_a_self() {
12+
std::cout << "lib_a_self called" << std::endl;
13+
}
14+
}

play/lib_a.h

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,8 @@
33

44
#include <iostream>
55

6-
#include "lib_b.h"
7-
86
namespace lib_a {
9-
void lib_a_function() {
10-
std::cout << "lib_a_function called" << std::endl;
11-
lib_b::lib_b_self();
12-
}
7+
void lib_a_function();
138

14-
void lib_a_self() {
15-
std::cout << "lib_a_self called" << std::endl;
16-
}
9+
void lib_a_self();
1710
}

play/lib_b.cc

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
#include <iostream>
22

3-
namespace lib_a {
4-
void lib_a_function() {
5-
// This function is intentionally left empty.
6-
std::cout << "lib_a_function called" << std::endl;
3+
#include "lib_a.h"
4+
5+
namespace lib_b {
6+
void lib_b_function() {
7+
std::cout << "lib_b_function called" << std::endl;
8+
lib_a::lib_a_self();
9+
}
10+
11+
void lib_b_self() {
12+
std::cout << "lib_b_self called" << std::endl;
713
}
814
}

play/lib_b.h

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,8 @@
22

33
#include <iostream>
44

5-
#include "lib_a.h"
6-
75
namespace lib_b {
8-
void lib_b_function() {
9-
std::cout << "lib_b_function called" << std::endl;
10-
lib_a::lib_a_self();
11-
}
6+
void lib_b_function();
127

13-
void lib_b_self() {
14-
std::cout << "lib_b_self called" << std::endl;
15-
}
8+
void lib_b_self();
169
}

src/gossip/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ add_library(small_gossip
55

66
target_link_libraries(small_gossip
77
PRIVATE
8+
small::server_info
89
spdlog
910
absl::status
1011
)

src/gossip/gossip.cc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
// local libraries
3131
// =====================================================================
3232

33+
#include "src/server_info/info.h"
34+
3335
// =====================================================================
3436
// self header
3537
// =====================================================================
@@ -44,9 +46,10 @@ GossipMessage::GossipMessage(const std::string& message) : message(message) {
4446

4547
GossipServer* GossipServer::instance_ptr = nullptr;
4648

47-
void GossipServer::init_instance() {
49+
void GossipServer::init_instance(
50+
const small::server_info::ImmutableInfo& self_info) {
4851
if (instance_ptr == nullptr) {
49-
instance_ptr = new GossipServer();
52+
instance_ptr = new GossipServer(self_info);
5053
} else {
5154
SPDLOG_ERROR("gossip server instance already initialized");
5255
}

src/gossip/gossip.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@
2121
#include <set>
2222
#include <string>
2323

24+
// =====================================================================
25+
// local libraries
26+
// =====================================================================
27+
28+
#include "src/server_info/info.h"
29+
2430
namespace small::gossip {
2531

2632
class GossipMessage {
@@ -45,11 +51,16 @@ class GossipServer {
4551
// singleton instance - protected constructor
4652
GossipServer() = default;
4753

54+
explicit GossipServer(const small::server_info::ImmutableInfo& self_info)
55+
: self_info(self_info) {}
56+
4857
// singleton instance - protected destructor
4958
~GossipServer() = default;
5059

5160
void transmit_message(const GossipMessage& message);
5261

62+
small::server_info::ImmutableInfo self_info;
63+
5364
public:
5465
// singleton instance - assignment-blocker
5566
void operator=(const GossipServer&) = delete;
@@ -58,7 +69,8 @@ class GossipServer {
5869
GossipServer(const GossipServer&) = delete;
5970

6071
// singleton instance - init api
61-
static void init_instance();
72+
static void init_instance(
73+
const small::server_info::ImmutableInfo& self_info);
6274

6375
// singleton instance - get api
6476
static GossipServer* get_instance();

src/server/server.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@ int RunServer(const small::server_info::ImmutableInfo& args) {
658658

659659
small::catalog::Catalog::InitInstance();
660660

661-
small::gossip::GossipServer::init_instance();
661+
small::gossip::GossipServer::init_instance(args);
662662
// === initialize singleton instances end ===
663663

664664
SPDLOG_INFO(

0 commit comments

Comments
 (0)