|
| | ThreadManager (QEventBus &qBus) |
| | Construct a ThreadManager bound to a QEventBus.
|
|
| ~ThreadManager () |
| | Destructor cleans up managed threads and subscriptions.
|
| template<typename F> |
| Thread * | createThread (const eastl::string &name, F func) |
| | Create (and store) a Thread from a generic callable.
|
| template<typename C> |
| Thread * | createThread (const eastl::string &name, void(C::*func)(), C *object) |
| | Create (and store) a Thread for a member function on an object.
|
| void | launch (Thread *th) |
| | Launch a previously created Thread instance.
|
| void | launch (const eastl::string &name) |
| | Convenience: launches the thread with the given name.
|
| void | waitAll () |
| | Block until all managed threads have finished executing.
|
| void | cleanupFinished () |
| | Remove and cleanup finished threads from internal storage.
|
| void | printStats () |
| | Print statistics (e.g. runtime durations) for managed threads.
|
| size_t | activeCount () const |
| | Count of currently active (non-finished) threads.
|
◆ ThreadManager()
| mce::ThreadManager::ThreadManager |
( |
QEventBus & | qBus | ) |
|
|
explicit |
Construct a ThreadManager bound to a QEventBus.
- Parameters
-
| qBus | Reference to the application's QEventBus used to post thread events. |
The ThreadManager subscribes to thread lifecycle events on qBus to maintain accurate bookkeeping.
◆ activeCount()
| size_t mce::ThreadManager::activeCount |
( |
| ) |
const |
Count of currently active (non-finished) threads.
- Returns
- Number of active threads being tracked.
◆ cleanupFinished()
| void mce::ThreadManager::cleanupFinished |
( |
| ) |
|
Remove and cleanup finished threads from internal storage.
This method may be used regularly to free resources held for threads that have already completed.
◆ createThread() [1/2]
template<typename F>
| Thread * mce::ThreadManager::createThread |
( |
const eastl::string & | name, |
|
|
F | func ) |
|
inline |
Create (and store) a Thread from a generic callable.
- Template Parameters
-
| F | Callable type (lambda, functor or function pointer). |
- Parameters
-
| name | Human readable name for the thread. |
| func | Callable to execute when the thread runs. |
- Returns
- Pointer to the created Thread (owned by ThreadManager).
The returned Thread pointer is non-owning; ThreadManager retains ownership in its internal storage (threadStorage). The thread is created but not launched — call launch() to start it.
◆ createThread() [2/2]
template<typename C>
| Thread * mce::ThreadManager::createThread |
( |
const eastl::string & | name, |
|
|
void(C::* | func )(), |
|
|
C * | object ) |
|
inline |
Create (and store) a Thread for a member function on an object.
- Template Parameters
-
| C | Class type of the target object. |
- Parameters
-
| name | Human readable name for the thread. |
| func | Pointer to the member function to call. |
| object | Pointer to the object instance on which to call the member function. |
- Returns
- Pointer to the created Thread (owned by ThreadManager).
Creates a Thread adapter that will call (object->*func)() when executed.
◆ launch() [1/2]
| void mce::ThreadManager::launch |
( |
const eastl::string & | name | ) |
|
Convenience: launches the thread with the given name.
- Parameters
-
| name | Name of the thread to launch. |
Finds the Thread associated with name and launches it. If multiple threads share the same name behavior depends on underlying container order.
◆ launch() [2/2]
| void mce::ThreadManager::launch |
( |
Thread * | th | ) |
|
◆ printStats()
| void mce::ThreadManager::printStats |
( |
| ) |
|
Print statistics (e.g. runtime durations) for managed threads.
Implementations should format and output info about active/finished threads using the project's logging facilities.
◆ waitAll()
| void mce::ThreadManager::waitAll |
( |
| ) |
|
Block until all managed threads have finished executing.
Joins/waits any active threads tracked by this manager.
The documentation for this class was generated from the following files: