ALib C++ Library
Library Version: 2412 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
DWManager Class Reference

Description:

Attention
This class belongs to module ALib ThreadModel, which is not in a stable and consistent state, yet. Also this type is considered experimental.

This singleton-class manages worker threads of type DedicatedWorker. Such threads are started by adding them to the singleton instance of this type and are stopped with removal.

DedicatedWorkers use this type's PoolAllocator to create and dispose Job objects and derived types are allowed to allocate resources in its MonoAllocator.

Definition at line 43 of file dedicatedworker.hpp.

#include <dedicatedworker.hpp>

Inheritance diagram for DWManager:
[legend]
Collaboration diagram for DWManager:
[legend]

Public Method Index:

ALIB_API void Add (DedicatedWorker &thread)
 
MonoAllocatorGetAllocator ()
 
PoolAllocatorGetPoolAllocator ()
 
ALIB_API bool Remove (DedicatedWorker &thread, Priority stopPriority=Priority::Lowest)
 
ALIB_API void RemoveAll (Priority stopPriority=Priority::Lowest)
 
ALIB_API bool WaitForAllIdle (Ticks::Duration timeout, Ticks::Duration dbgWarnAfter)
 
- Public Method Index: inherited from Singleton< DWManager >
virtual ~Singleton ()
 Virtual destructor.
 
- Public Method Index: inherited from Lock
 ~Lock () override
 Destructor. With debug-compilations, asserts that this lock is not acquired.
 
ALIB_API void Acquire (ALIB_DBG_TAKE_CI)
 
virtual ALIB_API bool DCSIsAcquired () const override
 
virtual ALIB_API bool DCSIsSharedAcquired () const override
 
ALIB_API void Release (ALIB_DBG_TAKE_CI)
 
ALIB_API bool TryAcquire (ALIB_DBG_TAKE_CI)
 
- Public Method Index: inherited from DbgCriticalSections::AssociatedLock
virtual ~AssociatedLock ()
 Virtual Destructor.
 

Protected Field Index:

MonoAllocator ma
 Mono allocator. Used for commands and by DedicatedWorkers.
 
PoolAllocator pool
 Pool allocator. Used for command objects.
 
List< MonoAllocator, DedicatedWorker * > workers
 The list of workers.
 
- Protected Field Index: inherited from Lock
std::mutex mutex
 

Private Method Index:

ALIB_API DWManager ()
 Constructor.
 

Additional Inherited Members

- Public Static Method Index: inherited from Singleton< DWManager >
static DWManagerGetSingleton ()
 
- Public Field Index: inherited from Lock
DbgLockAsserter Dbg
 The debug tool instance.
 
- Protected Static Field Index: inherited from Singleton< DWManager >
static DWManagersingleton
 A pointer to the one and only singleton.
 

Friends And Related Entity Details:

◆ singletons::Singleton< DWManager >

friend class singletons::Singleton< DWManager >
friend

Definition at line 1 of file dedicatedworker.hpp.

Field Details:

◆ ma

MonoAllocator ma
protected

Mono allocator. Used for commands and by DedicatedWorkers.

Definition at line 51 of file dedicatedworker.hpp.

◆ pool

PoolAllocator pool
protected

Pool allocator. Used for command objects.

Definition at line 54 of file dedicatedworker.hpp.

◆ workers

List<MonoAllocator, DedicatedWorker*> workers
protected

The list of workers.

Definition at line 57 of file dedicatedworker.hpp.

Constructor(s) / Destructor Details:

◆ DWManager()

DWManager ( )
private

Constructor.

Definition at line 48 of file dedicatedworker.cpp.

Method Details:

◆ Add()

void Add ( DedicatedWorker & thread)

Adds and starts a worker.

Parameters
threadThe thread to add.

Definition at line 62 of file dedicatedworker.cpp.

Here is the call graph for this function:

◆ GetAllocator()

MonoAllocator & GetAllocator ( )
inline

Allows access to the singleton instances' allocator.

Returns
The monotonic allocator.

Definition at line 66 of file dedicatedworker.hpp.

◆ GetPoolAllocator()

PoolAllocator & GetPoolAllocator ( )
inline

Allows access to the singleton instances' pool allocator.

Returns
The pool allocator.

Definition at line 70 of file dedicatedworker.hpp.

◆ Remove()

bool Remove ( DedicatedWorker & thread,
Priority stopPriority = Priority::Lowest )

Remove a previously added worker. The thread is stopped by invoking DedicatedWorker::ScheduleStop using the given priority. It is waited until it exits, and finally the thread is joined.
With debug-compilations, an ALib warning is raised every second if the thread does not stop.

Parameters
threadThe thread to remove.
stopPriorityThe priority passed to DedicatedWorker::ScheduleStop. Use Lowest (the default) to ensure that all other commands are duly executed before exiting.
Returns
true if the thread was found and removed, false otherwise.

Definition at line 73 of file dedicatedworker.cpp.

Here is the call graph for this function:

◆ RemoveAll()

void RemoveAll ( Priority stopPriority = Priority::Lowest)

Stops execution and terminates all workers by invoking DedicatedWorker::ScheduleStop.
After this method has been invoked, no further commands should be scheduled, even if the given priority equals Lowest. This should be assured by the using code.

With debug-compilations, an ALib warning is raised every second until all managed threads stopped.

Parameters
stopPriorityThe priority passed to DedicatedWorker::ScheduleStop. Use Lowest (the default) to ensure that all other commands are duly executed before exiting.

Definition at line 157 of file dedicatedworker.cpp.

Here is the call graph for this function:

◆ WaitForAllIdle()

bool WaitForAllIdle ( Ticks::Duration timeout,
Ticks::Duration dbgWarnAfter )

Waits until all threads are idle.

Parameters
timeoutThe maximum time to wait.
dbgWarnAfterThe time after which a warning message will be printed to the debug log if the timeout was reached.
This parameter is only available in debug-compilations and thus should be passed using macro ALIB_DBG.
Returns
true if all threads are idle, false otherwise.

Definition at line 111 of file dedicatedworker.cpp.

Here is the call graph for this function:

The documentation for this class was generated from the following files: