asge::concurrent::_internal::Worker
A thread pool worker that continuously drains jobs from a shared queue.
#include <ThreadPool.hpp>Inherits from asge::concurrent::Thread.
Inheritance
classDiagram
class N2["asge::concurrent::Thread"]
class N1["asge::concurrent::_internal::Worker"]
N2 <|-- N1
click N2 href "classasge_1_1concurrent_1_1Thread.html"
click N1 href "classasge_1_1concurrent_1_1__internal_1_1Worker.html"
Collaboration
classDiagram
class N2["asge::concurrent::Thread"]
class N1["asge::concurrent::_internal::Worker"]
N2 <|-- N1
click N2 href "classasge_1_1concurrent_1_1Thread.html"
click N1 href "classasge_1_1concurrent_1_1__internal_1_1Worker.html"
Worker extends Thread with a single responsibility: loop over a shared job_queue, pop executor_pointer entries as they become available, and call Execute() on each. It holds no ownership over the queue — only a reference — so the ThreadPool that owns both the queue and the workers must ensure the queue outlives all workers.
Each Worker is assigned a unique human-readable name ("Worker_1", "Worker_2", ...) via a static counter, which aids debugging and profiling.
Workers are move-constructible to allow storage in a std::vector, but are non-copyable since they hold a mutable queue reference and manage a live thread.
The static ID counter (s_Id) is not thread-safe. Workers are expected to be constructed sequentially during ThreadPool initialisation, not concurrently.
ThreadPool — owns the queue and the worker vector.
IExecuter — the interface each dequeued job implements.
Private Types
Static Private Attributes
Private Attributes
Private Member Functions
Implements the internal thread logic.
This method must implement only the internal thread logic inside the thread loop, which is instead managed outside the particular thread implementation. Therefore, all other conditions that might be return the thread execution must be specified in this method. To cancel the thread, the Cancel function on the context shall be called.
Public Member Functions
Worker(job_queue_ref inQueue, context_pointer inCtx)Worker(Worker &&)=defaultWorker(Worker const &)=delete~Worker() override