Ardour  9.0-pre0-582-g084a23a80d
CrossThreadChannel Class Reference

#include <crossthread.h>

Public Member Functions

 CrossThreadChannel (bool non_blocking)
 
 ~CrossThreadChannel ()
 
void wakeup ()
 
int deliver (char msg)
 
int receive (char &msg, bool wait=false)
 
void drain ()
 
void set_receive_handler (sigc::slot< bool, Glib::IOCondition > s)
 
void attach (Glib::RefPtr< Glib::MainContext >)
 

Private Member Functions

bool poll_for_request ()
 

Private Attributes

GIOChannel * receive_channel
 
GSource * receive_source
 
sigc::slot< bool, Glib::IOCondition > receive_slot
 
int fds [2]
 

Friends

gboolean cross_thread_channel_call_receive_slot (GIOChannel *, GIOCondition condition, void *data)
 

Detailed Description

A simple abstraction of a mechanism of signalling one thread from another. The signaller calls wakeup() to tell the signalled thread to check for work to be done.

This implementation provides both selectable() for use in direct poll/select-based event loops, and a Glib::IOSource via ios() for use in Glib main loop based situations.

Definition at line 44 of file crossthread.h.

Constructor & Destructor Documentation

◆ CrossThreadChannel()

CrossThreadChannel::CrossThreadChannel ( bool  non_blocking)

if non_blocking is true, the channel will not cause blocking when used in an event loop based on poll/select or the glib main loop.

◆ ~CrossThreadChannel()

CrossThreadChannel::~CrossThreadChannel ( )

Member Function Documentation

◆ attach()

void CrossThreadChannel::attach ( Glib::RefPtr< Glib::MainContext >  )

◆ deliver()

int CrossThreadChannel::deliver ( char  msg)

◆ drain()

void CrossThreadChannel::drain ( )

empty the channel of all requests. Typically this is done as soon as input is noticed on the channel, because the handler will look at a separately managed work queue. The actual number of queued "wakeups" in the channel will not be important.

◆ poll_for_request()

bool CrossThreadChannel::poll_for_request ( )
private

◆ receive()

int CrossThreadChannel::receive ( char &  msg,
bool  wait = false 
)

if using deliver() to wakeup the listening thread, then the listener should call receive() to fetch the message type from the channel.

wait = true only make sense for non_blocking channels, it polls for data to become available.

◆ set_receive_handler()

void CrossThreadChannel::set_receive_handler ( sigc::slot< bool, Glib::IOCondition >  s)

◆ wakeup()

void CrossThreadChannel::wakeup ( )

Tell the listening thread that is has work to do.

Friends And Related Function Documentation

◆ cross_thread_channel_call_receive_slot

gboolean cross_thread_channel_call_receive_slot ( GIOChannel *  ,
GIOCondition  condition,
void *  data 
)
friend

Member Data Documentation

◆ fds

int CrossThreadChannel::fds[2]
private

Definition at line 97 of file crossthread.h.

◆ receive_channel

GIOChannel* CrossThreadChannel::receive_channel
private

Definition at line 90 of file crossthread.h.

◆ receive_slot

sigc::slot<bool,Glib::IOCondition> CrossThreadChannel::receive_slot
private

Definition at line 92 of file crossthread.h.

◆ receive_source

GSource* CrossThreadChannel::receive_source
private

Definition at line 91 of file crossthread.h.


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