Kodi Documentation 22.0
Kodi is an open source media player and entertainment hub.
Loading...
Searching...
No Matches
CWorkerGate Class Reference

Lock-free cooperative gate for pausing a worker thread. More...

#include <MediaPipelineWebOS.h>

Classes

class  Lock
 RAII guard – pauses the worker on construction, resumes on destruction. More...
 

Public Member Functions

void Checkpoint ()
 Called by the worker thread at the top of every loop iteration.
 
void OnExit ()
 Called by the worker thread just before it exits its loop.
 
void SetRunning (const bool running)
 Indicate whether the associated worker thread is running.
 

Detailed Description

Lock-free cooperative gate for pausing a worker thread.

The worker calls Checkpoint() each loop iteration. If a pause has been requested it blocks (via std::atomic::wait) until the requester releases.

Other threads obtain a Lock RAII guard which requests the pause, waits for the worker to reach its checkpoint, and resumes the worker on destruction.

Member Function Documentation

◆ Checkpoint()

void CWorkerGate::Checkpoint ( )
inline

Called by the worker thread at the top of every loop iteration.

If a pause has been requested the call blocks until the requester calls Resume() (typically via Lock destruction).

◆ OnExit()

void CWorkerGate::OnExit ( )
inline

Called by the worker thread just before it exits its loop.

Ensures any thread blocked in Pause() is woken up.

◆ SetRunning()

void CWorkerGate::SetRunning ( const bool running)
inline

Indicate whether the associated worker thread is running.

Must be set to true before the worker loop and false after.


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