File tree Expand file tree Collapse file tree 9 files changed +48
-29
lines changed Expand file tree Collapse file tree 9 files changed +48
-29
lines changed Original file line number Diff line number Diff line change 11{
22 "C_Cpp.default.compileCommands" : " ${workspaceFolder}/build/debug/compile_commands.json" ,
3- "cmake.configureArgs" : [
4- " --fresh"
5- ],
63}
Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 33
44#include < iostream>
55
6- #include " lib_b.h"
7-
86namespace 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}
Original file line number Diff line number Diff line change 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}
Original file line number Diff line number Diff line change 22
33#include < iostream>
44
5- #include " lib_a.h"
6-
75namespace 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}
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ add_library(small_gossip
55
66target_link_libraries (small_gossip
77 PRIVATE
8+ small::server_info
89 spdlog
910 absl::status
1011)
Original file line number Diff line number Diff line change 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
4547GossipServer* 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 }
Original file line number Diff line number Diff line change 2121#include < set>
2222#include < string>
2323
24+ // =====================================================================
25+ // local libraries
26+ // =====================================================================
27+
28+ #include " src/server_info/info.h"
29+
2430namespace small ::gossip {
2531
2632class 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 ();
Original file line number Diff line number Diff 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 (
You can’t perform that action at this time.
0 commit comments