14using namespace std::literals::chrono_literals;
23, triggerList (monomem::GLOBAL_ALLOCATOR)
30 ALIB_WARNING(
"MGTHR",
"Trigger destroyed without having run" )
34 ALIB_ERROR(
"MGTHR",
"Trigger destroyed without being terminated" )
44 bool isExisting=
false;
46 if ( it.Target == &triggered )
56 now + ( initialWakeup ? Ticks::Duration()
61 "Duplicate registration of triggered object \"" << triggered.
Name <<
"\"." )
76 if(it->Target == &triggered)
90 <<
"\" not found for de-registering with trigger list" )
104 ALIB_MESSAGE(
"MGTHR",
"Internal trigger-thread exiting" )
121 "Trigger::Do() called twice!\n"
122 "Hint: Did you start the trigger thread and in addition 'manually' invoked Do()?\n"
123 " Only on sort of execution is allowed." )
131 && now.
Reset() < until )
134 Ticks nextTriggerTime= until;
138 if( it.NextWakeup <= now )
140 it.Target->trigger();
142 it.NextWakeup= now + it.Target->triggerPeriod();
146 nextTriggerTime= (std::min)(nextTriggerTime, it.NextWakeup);
virtual ALIB_API void Start()
ALIB_API void Add(Triggered &triggered, bool initialWakeup=false)
bool internalThreadMode
Denotes whether or not the trigger is currently used in internal thread mode.
virtual ALIB_API void Stop()
Stops the trigger thread and joins it.
virtual ALIB_API void Run() override
Implementation of the parent interface (virtual abstract).
ALIB_API Trigger()
Constructor.
virtual ALIB_API ~Trigger() override
Destructor.
ALIB_API void Remove(Triggered &triggered)
ALIB_API void Do(Ticks until)
List< MonoAllocator, TriggerEntry > triggerList
The list of registered triggered objects.
virtual Ticks::Duration triggerPeriod()=0
@ Started
Method Start was invoked but not running, yet.
@ Terminated
The thread is terminated.
State state
Internal flag to indicate if the thread is alive.
virtual ALIB_API void Join()
static Ticks EndOfEpoch()
#define ALIB_WARNING(...)
#define ALIB_COMMA_CALLER_PRUNED
#define ALIB_MESSAGE(...)
#define ALIB_LOCK_RECURSIVE_WITH(lock)
#define ALIB_ASSERT_ERROR(cond,...)
#define ALIB_CALLER_PRUNED
constexpr bool IsNull(const T &t)
constexpr void SetNull(const T &t)
ALIB_API RecursiveLock GLOBAL_ALLOCATOR_LOCK
NLocalString< 256 > NString256
Type alias name for TLocalString<nchar,256>.
std::thread::id AssertExclusiveWaiter
void WaitForNotification(ALIB_DBG_TAKE_CI)
DbgConditionAsserter Dbg
The debug tool instance.
void Acquire(ALIB_DBG_TAKE_CI)
void ReleaseAndNotify(ALIB_DBG_TAKE_CI)