Raven Engine v0.1
Loading...
Searching...
No Matches
Raven::Worker Class Reference

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.

Detailed Description

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.

Constructor & Destructor Documentation

◆ Worker()

Raven::Worker::Worker ( usize id,
JobQueueType * queue )
inlineexplicit

Constructs a Worker.

Parameters
idA unique identifier for this worker.
queuePointer to the shared job queue to poll.

Member Function Documentation

◆ Start()

void Raven::Worker::Start ( )
inline

Starts the worker thread, invoking its Run loop.

◆ Stop()

void Raven::Worker::Stop ( )
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.


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