Commit 5e55e81a authored by Dominik Charousset's avatar Dominik Charousset

Provide manual way to set node ID, relates #263

parent 079f6372
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include "caf/fwd.hpp" #include "caf/fwd.hpp"
#include "caf/node_id.hpp"
#include "caf/detail/cas_weak.hpp" #include "caf/detail/cas_weak.hpp"
namespace caf { namespace caf {
...@@ -61,6 +62,9 @@ class singletons { ...@@ -61,6 +62,9 @@ class singletons {
static node_id get_node_id(); static node_id get_node_id();
// returns false if singleton is already defined
static bool set_node_id(node_id::data* ptr);
static scheduler::abstract_coordinator* get_scheduling_coordinator(); static scheduler::abstract_coordinator* get_scheduling_coordinator();
// returns false if singleton is already defined // returns false if singleton is already defined
......
...@@ -126,6 +126,12 @@ node_id singletons::get_node_id() { ...@@ -126,6 +126,12 @@ node_id singletons::get_node_id() {
return node_id{lazy_get(s_node_id, s_node_id_mtx)}; return node_id{lazy_get(s_node_id, s_node_id_mtx)};
} }
bool singletons::set_node_id(node_id::data* ptr) {
auto res = lazy_get(s_node_id, s_node_id_mtx,
[ptr] { return ptr; });
return res == ptr;
}
logging* singletons::get_logger() { logging* singletons::get_logger() {
return lazy_get(s_logger, s_logger_mtx); return lazy_get(s_logger, s_logger_mtx);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment