15 #if ALIB_DEBUG_CRITICAL_SECTIONS
16 ma.DbgCriticalSectionsPH.Get()->DCSLock=
this;
46 int nextWarnSecond= 1;
51 if( waitCheck.
Age().InAbsoluteSeconds() == nextWarnSecond ) {
53 "DWManager::Remove: Waiting on thread \"{}\" to stop. State::{}, Load: ",
67 ALIB_DBG(, Ticks::Duration dbgWarnAfter) ) {
84 if( nextWarning.Age() > dbgWarnAfter) {
85 std::vector<std::any> args; args.reserve(32);
86 args.emplace_back(
"Waiting on {} thread(s) to become idle.\n");
87 args.emplace_back( cntRunning );
91 if ( it->Load() > 0 ) {
92 args.emplace_back( ++tNr );
93 args.emplace_back(
": {},\tState::{},\t Load: \n" );
94 args.emplace_back( it->GetName() );
95 args.emplace_back( it->state );
96 args.emplace_back( it->Load() );
104 if (waitStart.
Age() > timeout)
115 int nextWarnSecond= 1; )
119 if( !it->StopIsScheduled() )
120 it->ScheduleStop( stopPriority );
130 if( cntRunning == 0 )
135 if( waitCheck.Age().InAbsoluteSeconds() == nextWarnSecond ) {
136 std::vector<std::any> args; args.reserve(32);
137 args.emplace_back(
"DWManager Termination: Waiting on {} thread(s) to stop.\n");
138 args.emplace_back( cntRunning );
141 args.emplace_back( ++tNr );
142 args.emplace_back(
": {},\tState::{},\t Load: \n" );
143 args.emplace_back( it->GetName() );
144 args.emplace_back( it->state );
145 args.emplace_back( it->Load() );
166 auto it=
queue.begin();
167 while(it !=
queue.end()) {
168 if(jobInfo.priority <= it->priority )
174 queue.Insert(it, jobInfo );
177 std::vector<std::any> args; args.reserve(32);
178 args.emplace_back(
"Queue({}) Job({}) pushed. P::{} Keep: ");
179 args.emplace_back(
queue.size() );
180 args.emplace_back( &jobInfo.job->ID );
181 args.emplace_back( jobInfo.priority );
182 args.emplace_back( jobInfo.keepJob );
197 std::pair<Job*, bool> result= {
queue.back().job,
queue.back().keepJob };
204 std::vector<std::any> args; args.reserve(32);
205 args.emplace_back(
"Queue({}) Job({}) pushed. P::{} Keep: ");
206 args.emplace_back(
length );
207 args.emplace_back( &result.first->ID );
208 args.emplace_back( dbgPriority );
209 args.emplace_back( result.second );
220 auto jobInfo =
pop();
229 auto size= job.JobToDelete->SizeOf();
230 job.JobToDelete->~Job();
231 manager.GetPoolAllocator().free( job.JobToDelete, size );
244 if (jobInfo.first->Is<
JobStop>() ) {
248 manager.GetPoolAllocator().free( jobInfo.first,
sizeof(
JobStop) );
253 if ( jobInfo.first->Do() ) {
255 if ( !jobInfo.second )
257 auto size= jobInfo.first->SizeOf();
258 jobInfo.first->~Job();
259 manager.GetPoolAllocator().free( jobInfo.first, size );
267 "Job of type <{}> passed to DedicatedWorker, which was neither recognized by\n"
268 "the specialist nor has it a Job::Do() implementation!", &jobInfo.first->ID )
275 "DedicatedWorker \"{}\" has jobs still queued when stopped!",
GetName(),
Load() )
277 ALIB_MESSAGE(
"TMOD",
"DedicatedWorker \"{}\" is stopping (leaving method Run()).",
GetName() )
#define ALIB_MESSAGE(domain,...)
#define ALIB_ASSERT(cond, domain)
#define ALIB_WARNING(domain,...)
#define ALIB_ASSERT_WARNING(cond, domain,...)
#define ALIB_ERROR(domain,...)
#define ALIB_ASSERT_ERROR(cond, domain,...)
#define ALIB_CALLER_PRUNED
#define ALIB_LOCK_WITH(lock)
ListMA< DedicatedWorker * > workers
The list of workers.
MonoAllocator ma
Mono allocator. Used for commands and by DedicatedWorkers.
void RemoveAll(Priority stopPriority=Priority::Lowest)
void Add(DedicatedWorker &thread)
bool Remove(DedicatedWorker &thread, Priority stopPriority=Priority::Lowest)
PoolAllocator pool
Pool allocator. Used for command objects.
bool WaitForAllIdle(Ticks::Duration timeout, Ticks::Duration dbgWarnAfter)
virtual void Run() override
virtual bool process(Job &vjob)
std::pair< Job *, bool > pop()
void pushAndRelease(QueueElement &&jobInfo)
DWManager & manager
Reference to #"%DWManager" instance.
int length
The current number of jobs in the queue.
bool stopJobExecuted
Flag which is set when the stop-job was executed.
void ScheduleStop(Priority priority)
List< QueueElement > queue
alib::Ticks statLastJobExecution
virtual const character * GetName() const
DbgLockAsserter Dbg
The debug tool instance.
@ Terminated
The thread is terminated.
static void SleepMicros(int64_t microseconds)
void raise(const CallerInfo &ci, int type, std::string_view domain, const std::span< std::any > &args)
Priority
Possible priorities of jobs assigned to an #"DedicatedWorker".
time::Ticks Ticks
Type alias in namespace #"%alib".
Job * JobToDelete
The job to be deleted.
The stop job sent by method #"ScheduleStop".
Container element of the queue.
virtual void PrepareDeferredDeletion()
void WaitForNotification(ALIB_DBG_TAKE_CI)
void Acquire(ALIB_DBG_TAKE_CI)
void ReleaseAndNotify(ALIB_DBG_TAKE_CI)