Audio Processing Framework (APF) version 0.5.0
Classes | List of all members
apf::CommandQueue Class Reference

Manage command queue from non-realtime thread to realtime thread. More...

#include <apf/commandqueue.h>

Inheritance diagram for apf::CommandQueue:
Inheritance graph
[legend]

Classes

struct  Command
 Abstract base class for realtime commands. More...
 
class  WaitCommand
 Dummy command to synchronize with non-realtime thread. More...
 

Public Member Functions

Functions to be called from the non-realtime thread

If there are multiple non-realtime threads, access has to be locked!

 CommandQueue (size_t size)
 Constructor. More...
 
 ~CommandQueue ()
 Destructor. More...
 
void push (Command *cmd)
 Push a command to be executed in the realtime thread. More...
 
void wait ()
 Wait for realtime thread. More...
 
void cleanup_commands ()
 Clean up all commands in the cleanup-queue. More...
 
bool deactivate ()
 Deactivate queue; process following commands in the non-realtime thread. More...
 
void reactivate ()
 Re-activate queue. More...
 

Functions to be called from the realtime thread

void process_commands ()
 Execute all commands in the queue. More...
 
bool commands_available () const
 Check if commands are available. More...
 

Detailed Description

Manage command queue from non-realtime thread to realtime thread.

Commands can be added in the non-realtime thread with push().

Commands are executed when process_commands() is called from the realtime thread.

Definition at line 48 of file commandqueue.h.

Constructor & Destructor Documentation

◆ CommandQueue()

apf::CommandQueue::CommandQueue ( size_t  size)
inlineexplicit

Constructor.

Parameters
sizemaximum number of commands in queue.

Definition at line 88 of file commandqueue.h.

◆ ~CommandQueue()

apf::CommandQueue::~CommandQueue ( )
inline

Destructor.

Attention
Commands in the cleanup queue are cleaned up, but commands in the process queue are ignored and their memory is not freed!

Definition at line 97 of file commandqueue.h.

References cleanup_commands().

Member Function Documentation

◆ push()

void apf::CommandQueue::push ( Command cmd)
inline

Push a command to be executed in the realtime thread.

The command will be cleaned up when it comes back from the realtime thread. If the CommandQueue is inactive, the command is not queued but executed and cleaned up immediately.

Parameters
cmdThe command to be executed.

Definition at line 192 of file commandqueue.h.

References cleanup_commands(), and apf::CommandQueue::Command::execute().

Referenced by wait().

◆ wait()

void apf::CommandQueue::wait ( )
inline

Wait for realtime thread.

Push an empty command and wait for its return.

Definition at line 219 of file commandqueue.h.

References cleanup_commands(), and push().

◆ cleanup_commands()

void apf::CommandQueue::cleanup_commands ( )
inline

Clean up all commands in the cleanup-queue.

Note
This function must be called from the non-realtime thread.

Definition at line 110 of file commandqueue.h.

Referenced by deactivate(), push(), reactivate(), wait(), and ~CommandQueue().

◆ deactivate()

bool apf::CommandQueue::deactivate ( )
inline

Deactivate queue; process following commands in the non-realtime thread.

Returns
true on success
Note
The queue must be empty. If not, the queue is not deactivated and false is returned.

Definition at line 121 of file commandqueue.h.

References cleanup_commands().

Referenced by apf::MimoProcessor< Derived, interface_policy, query_policy >::MimoProcessor().

◆ reactivate()

void apf::CommandQueue::reactivate ( )
inline

Re-activate queue.

See also
deactivate().

Definition at line 129 of file commandqueue.h.

References cleanup_commands().

◆ process_commands()

void apf::CommandQueue::process_commands ( )
inline

Execute all commands in the queue.

After execution, the commands are queued for cleanup in the non-realtime thread.

Note
This function must be called from the realtime thread.

Definition at line 145 of file commandqueue.h.

References apf::CommandQueue::Command::execute().

◆ commands_available()

bool apf::CommandQueue::commands_available ( ) const
inline

Check if commands are available.

Returns
true if commands are available.

Definition at line 161 of file commandqueue.h.


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