Ardour  9.0-pre0-582-g084a23a80d
ARDOUR::Worker Class Reference

#include <worker.h>

Public Member Functions

 Worker (Workee *workee, uint32_t ring_size, bool threaded=true)
 
 ~Worker ()
 
bool schedule (uint32_t size, const void *data)
 
bool respond (uint32_t size, const void *data)
 
void emit_responses ()
 
void set_synchronous (bool synchronous)
 

Private Member Functions

void run ()
 
bool verify_message_completeness (PBD::RingBuffer< uint8_t > *rb)
 

Private Attributes

Workee_workee
 
PBD::RingBuffer< uint8_t > * _requests
 
PBD::RingBuffer< uint8_t > * _responses
 
uint8_t * _response
 
PBD::Semaphore _sem
 
PBD::Thread_thread
 
bool _exit
 
bool _synchronous
 

Detailed Description

A worker for non-realtime tasks scheduled from another thread.

A worker may be a separate thread that runs to execute scheduled work asynchronously, or unthreaded, in which case work is executed immediately upon scheduling by the calling thread.

Definition at line 60 of file worker.h.

Constructor & Destructor Documentation

◆ Worker()

ARDOUR::Worker::Worker ( Workee workee,
uint32_t  ring_size,
bool  threaded = true 
)

◆ ~Worker()

ARDOUR::Worker::~Worker ( )

Member Function Documentation

◆ emit_responses()

void ARDOUR::Worker::emit_responses ( )

Emit any pending responses (audio thread).

◆ respond()

bool ARDOUR::Worker::respond ( uint32_t  size,
const void *  data 
)

Respond from work (worker thread).

Returns
false on error.

◆ run()

void ARDOUR::Worker::run ( )
private

◆ schedule()

bool ARDOUR::Worker::schedule ( uint32_t  size,
const void *  data 
)

Schedule work (audio thread).

Returns
false on error.

◆ set_synchronous()

void ARDOUR::Worker::set_synchronous ( bool  synchronous)
inline

Enable or disable synchronous execution.

If enabled, all work is performed immediately in schedule() regardless of whether or not the worker is threaded. This is used for exporting, where we want to temporarily execute all work synchronously but the worker is typically used threaded for live rolling.

Definition at line 91 of file worker.h.

◆ verify_message_completeness()

bool ARDOUR::Worker::verify_message_completeness ( PBD::RingBuffer< uint8_t > *  rb)
private

Peek in RB, get size and check if a block of 'size' is available.

Handle the unlikely edge-case, if we're called in between the responder writing 'size' and 'data'.

Parameters
rbthe ringbuffer to check
Returns
true if the message is complete, false otherwise

Member Data Documentation

◆ _exit

bool ARDOUR::Worker::_exit
private

Definition at line 112 of file worker.h.

◆ _requests

PBD::RingBuffer<uint8_t>* ARDOUR::Worker::_requests
private

Definition at line 107 of file worker.h.

◆ _response

uint8_t* ARDOUR::Worker::_response
private

Definition at line 109 of file worker.h.

◆ _responses

PBD::RingBuffer<uint8_t>* ARDOUR::Worker::_responses
private

Definition at line 108 of file worker.h.

◆ _sem

PBD::Semaphore ARDOUR::Worker::_sem
private

Definition at line 110 of file worker.h.

◆ _synchronous

bool ARDOUR::Worker::_synchronous
private

Definition at line 113 of file worker.h.

◆ _thread

PBD::Thread* ARDOUR::Worker::_thread
private

Definition at line 111 of file worker.h.

◆ _workee

Workee* ARDOUR::Worker::_workee
private

Definition at line 106 of file worker.h.


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