8 #ifndef FAIR_MQ_SHMEM_MONITOR_H_
9 #define FAIR_MQ_SHMEM_MONITOR_H_
16 #include <unordered_map>
25 std::string sessionId;
26 explicit operator std::string()
const {
return sessionId; }
32 explicit operator std::string()
const {
return shmId; }
37 BufferDebugInfo(
size_t offset, pid_t pid,
size_t size, uint64_t creationTime)
41 , fCreationTime(creationTime)
47 uint64_t fCreationTime;
53 Monitor(
const std::string& shmId,
bool selfDestruct,
bool interactive,
bool viewOnly,
unsigned int timeoutInMS,
unsigned int intervalInMS,
bool runAsDaemon,
bool cleanOnExit);
55 Monitor(
const Monitor&) =
delete;
66 static std::vector<std::pair<std::string, bool>>
Cleanup(
const ShmId& shmId,
bool verbose =
true);
70 static std::vector<std::pair<std::string, bool>>
Cleanup(
const SessionId& sessionId,
bool verbose =
true);
74 static std::vector<std::pair<std::string, bool>>
CleanupFull(
const ShmId& shmId,
bool verbose =
true);
78 static std::vector<std::pair<std::string, bool>>
CleanupFull(
const SessionId& sessionId,
bool verbose =
true);
80 static void PrintDebugInfo(
const ShmId& shmId);
81 static void PrintDebugInfo(
const SessionId& shmId);
82 static std::unordered_map<uint16_t, std::vector<BufferDebugInfo>> GetDebugInfo(
const ShmId& shmId);
83 static std::unordered_map<uint16_t, std::vector<BufferDebugInfo>> GetDebugInfo(
const SessionId& shmId);
85 static bool RemoveObject(
const std::string& name);
86 static bool RemoveFileMapping(
const std::string& name);
87 static bool RemoveQueue(
const std::string& name);
88 static bool RemoveMutex(
const std::string& name);
89 static bool RemoveCondition(
const std::string& name);
91 struct DaemonPresent : std::runtime_error {
using std::runtime_error::runtime_error; };
95 void MonitorHeartbeats();
106 unsigned int fTimeoutInMS;
107 unsigned int fIntervalInMS;
109 std::string fSegmentName;
110 std::string fManagementSegmentName;
111 std::string fControlQueueName;
112 std::atomic<bool> fTerminating;
113 std::atomic<bool> fHeartbeatTriggered;
114 std::chrono::high_resolution_clock::time_point fLastHeartbeat;
115 std::thread fSignalThread;
116 std::unordered_map<std::string, std::chrono::high_resolution_clock::time_point> fDeviceHeartbeats;