19#ifndef HEADER_CAN_BE_DELETED
20#define HEADER_CAN_BE_DELETED
22#include "utils/log.hpp"
23#include "utils/time.hpp"
40 std::atomic_bool m_can_be_deleted;
48 void resetCanBeDeleted() { m_can_be_deleted.store(
false); }
50 bool canBeDeletedNow() {
return m_can_be_deleted.load(); }
57 if (m_can_be_deleted.load())
return true;
59 Log::verbose(
"Thread",
"Start waiting %lf", start);
62 if(m_can_be_deleted.load())
64 Log::verbose(
"Thread",
65 "Waited %lf seconds for thread to become deleteable.",
74 Log::verbose(
"Thread",
"Waited for more than %f seconds for "
75 "thread to become deleteable",
A simple class that a adds a function to wait with a timeout for a class to be ready to be deleted.
Definition: can_be_deleted.hpp:38
CanBeDeleted()
Set this instance to be not ready to be deleted.
Definition: can_be_deleted.hpp:43
void setCanBeDeleted()
Sets this instance to be ready to be deleted.
Definition: can_be_deleted.hpp:46
bool waitForReadyToDeleted(float waiting_time)
Waits at most t seconds for this class to be ready to be deleted.
Definition: can_be_deleted.hpp:55
static double getRealTime(long startAt=0)
Returns a time based on an arbitrary 'epoch' (e.g.
Definition: time.cpp:95
static void sleep(int msec)
Sleeps for the specified amount of time.
Definition: time.hpp:134