1 #include "include/t4.h"
3 #include "include/rpc/rpc.h"
5 using namespace std::chrono;
9 t4_state::t4_state(char log_prefix) : log_thread_prefix(log_prefix) {
10 uint32_t seed = std::random_device()();
11 auto time = system_clock::now().time_since_epoch();
12 auto ticks = time / 1ns;
13 seed ^= (uint32_t)ticks;
15 seed ^= (uint32_t)pid;
16 auto tid = std::hash<std::thread::id>()(std::this_thread::get_id());
17 seed ^= (uint32_t)tid;
18 random_generator.seed(seed);
19 // make sure the clock will read differently next time!
20 std::this_thread::sleep_for(1us);
23 t4_state::~t4_state() {
24 lock ml(handle_cache_mutex);
26 shared_mgr.shutdown();
29 shared_ptr<rpcc> t4_state::get_handle(const string & destination) {
30 lock ml(handle_cache_mutex);
31 if (!handle_cache[destination])
32 handle_cache[destination] = std::make_shared<rpcc>(destination);
33 return handle_cache[destination];
36 void t4_state::erase_handle(const string & destination) {
37 lock ml(handle_cache_mutex);
38 handle_cache.erase(destination);