![]() |
Raven Engine v0.1
|
Background thread that fetches and executes jobs from a JobQueue. More...
#include <Worker.h>
Public Member Functions | |
| Worker (usize id, JobQueueType *queue) | |
| Constructs a Worker. | |
| void | Start () |
| Starts the worker thread, invoking its Run loop. | |
| void | Stop () |
| Signals the worker to stop and joins its thread. | |
Background thread that fetches and executes jobs from a JobQueue.
Each Worker owns a thread that runs the private Run() loop. Jobs are popped from the queue and executed. If no job is available, the thread yields.
The Worker class encapsulates a single background thread that continuously polls a shared JobQueue for new jobs. When a job is available, the worker executes it by calling its Execute() method. If no jobs are pending, the worker yields to avoid busy-waiting. The worker can be started and stopped cleanly, ensuring the thread is joined on shutdown.
|
inlineexplicit |
Constructs a Worker.
| id | A unique identifier for this worker. |
| queue | Pointer to the shared job queue to poll. |
|
inline |
Starts the worker thread, invoking its Run loop.
|
inline |
Signals the worker to stop and joins its thread.
Sets the running flag to false. If the thread is joinable, waits for it to finish execution.