Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
OSMQ Class Reference

This class provides a simple message queue. More...

#include <OS.hxx>

Public Member Functions

 OSMQ (size_t length, size_t item_size)
 Constructor.
 
 ~OSMQ ()
 Destructor.
 
void send (const void *data)
 Blocking send of a message to a queue.
 
int timedsend (const void *data, long long timeout)
 Send a message to a queue with a timeout.
 
void receive (void *data)
 Blocking receive a message from a queue.
 
int timedreceive (void *data, long long timeout)
 Receive a message from a queue.
 
int send_from_isr (const void *data, int *woken)
 Send of a message to a queue from ISR context.
 
int receive_from_isr (void *data, int *woken)
 Receive a message from a queue from ISR context.
 
int num_pending ()
 Return the number of messages pending in the queue.
 
int num_spaces ()
 Return the number of spaces available.
 
int pending_from_isr ()
 Return the number of messages pending in the queue from ISR context.
 
int is_full_from_isr ()
 Check if a queue is full from ISR context.
 

Private Member Functions

 OSMQ ()
 Default Constructor.
 
 DISALLOW_COPY_AND_ASSIGN (OSMQ)
 

Private Attributes

os_mq_t handle
 Private message queue handle.
 

Detailed Description

This class provides a simple message queue.

Definition at line 304 of file OS.hxx.

Constructor & Destructor Documentation

◆ OSMQ()

OSMQ::OSMQ ( size_t  length,
size_t  item_size 
)
inline

Constructor.

Parameters
lengthnumber of items the queue can hold
item_sizesize of each item in bytes in the queue

Definition at line 312 of file OS.hxx.

◆ ~OSMQ()

OSMQ::~OSMQ ( )
inline

Destructor.

Todo:
(Stuart Baker) need a way to destroy a message queue

Definition at line 320 of file OS.hxx.

Member Function Documentation

◆ is_full_from_isr()

int OSMQ::is_full_from_isr ( )
inline

Check if a queue is full from ISR context.

Returns
non-zero if the queue is full.

Definition at line 408 of file OS.hxx.

◆ num_pending()

int OSMQ::num_pending ( )
inline

Return the number of messages pending in the queue.

Returns
number of messages in the queue

Definition at line 384 of file OS.hxx.

◆ num_spaces()

int OSMQ::num_spaces ( )
inline

Return the number of spaces available.

Returns
number of spaces available

Definition at line 392 of file OS.hxx.

◆ pending_from_isr()

int OSMQ::pending_from_isr ( )
inline

Return the number of messages pending in the queue from ISR context.

Returns
number of messages in the queue

Definition at line 400 of file OS.hxx.

◆ receive()

void OSMQ::receive ( void *  data)
inline

Blocking receive a message from a queue.

Parameters
datalocation to copy message from the queue

Definition at line 346 of file OS.hxx.

◆ receive_from_isr()

int OSMQ::receive_from_isr ( void *  data,
int *  woken 
)
inline

Receive a message from a queue from ISR context.

Parameters
datalocation to copy message from the queue
wokenis the task woken up
Returns
OS_MQ_NONE on success, else OS_MQ_FULL

Definition at line 376 of file OS.hxx.

◆ send()

void OSMQ::send ( const void *  data)
inline

Blocking send of a message to a queue.

Parameters
datamessage to copy into queue

Definition at line 328 of file OS.hxx.

◆ send_from_isr()

int OSMQ::send_from_isr ( const void *  data,
int *  woken 
)
inline

Send of a message to a queue from ISR context.

Parameters
datamessage to copy into queue
wokenis the task woken up
Returns
OS_MQ_NONE on success, else OS_MQ_FULL

Definition at line 366 of file OS.hxx.

◆ timedreceive()

int OSMQ::timedreceive ( void *  data,
long long  timeout 
)
inline

Receive a message from a queue.

Parameters
datalocation to copy message from the queue
timeouttime in nanoseconds to wait for queue to have a message available
Returns
OS_MQ_NONE on success, OS_MQ_TIMEDOUT on timeout

Definition at line 356 of file OS.hxx.

◆ timedsend()

int OSMQ::timedsend ( const void *  data,
long long  timeout 
)
inline

Send a message to a queue with a timeout.

Parameters
datamessage to copy into queue
timeouttime in nanoseconds to wait for queue to be able to accept message
Returns
OS_MQ_NONE on success, OS_MQ_TIMEDOUT on timeout

Definition at line 338 of file OS.hxx.

Member Data Documentation

◆ handle

os_mq_t OSMQ::handle
private

Private message queue handle.

Definition at line 419 of file OS.hxx.


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