26#ifndef GOBY_MIDDLEWARE_COMMON_H
27#define GOBY_MIDDLEWARE_COMMON_H
31#include <sys/syscall.h>
35#include <boost/algorithm/string.hpp>
46 const int underscore_pos = 5;
48 boost::to_lower(name);
53inline std::string
thread_id(std::thread::id i = std::this_thread::get_id())
56 ss << std::hex << std::hash<std::thread::id>{}(i);
62inline uint64_t gettid()
65 pthread_threadid_np(NULL, &tid);
68#elif defined SYS_gettid
71 return syscall(SYS_gettid);
74#error "SYS_gettid unavailable on this system, and this is not an Apple system."
80 std::ifstream hs(
"/etc/hostname");
83 std::string
hostname((std::istreambuf_iterator<char>(hs)),
84 std::istreambuf_iterator<char>());
97 static const std::string host_id =
hostname();
98 static const std::string pid = std::to_string(getpid());
99 static const std::string full_pid = host_id + std::string(
"-p") + pid;
simple exception class for goby applications
const std::string & Layer_Name(T enum_t_value)
std::string full_process_and_thread_id(std::thread::id i=std::this_thread::get_id())
std::string to_string(goby::middleware::protobuf::Layer layer)
std::string full_process_id()
std::string thread_id(std::thread::id i=std::this_thread::get_id())
The global namespace for the Goby project.