Skyward boardcore
Loading...
Searching...
No Matches
Boardcore::SyncPacketQueue< pktLen, pktNum > Class Template Reference

A SyncPacketQueue is a SyncCircularBuffer of Packets. More...

#include <SyncPacketQueue.h>

Public Member Functions

bool put (uint8_t *msg, size_t msgLen)
 Try to append a given message to the packets queue.
 
const Packet< pktLen > get ()
 
const Packet< pktLen > pop ()
 
bool isFull ()
 
bool isEmpty ()
 
void waitUntilNotEmpty ()
 Blocks the calling thread until the queue is not empty.
 
size_t countReady ()
 
size_t countNotEmpty ()
 

Detailed Description

template<unsigned int pktLen, unsigned int pktNum>
class Boardcore::SyncPacketQueue< pktLen, pktNum >

A SyncPacketQueue is a SyncCircularBuffer of Packets.

The difference is that you pop() Packets but you append() bytes. The bytes will be appended to the first available packet and the next ones. This class is suitable for synchronization between two threads.

Template Parameters
pktLenMaximum length of each packet [bytes].
pktNumTotal number of packets.

Definition at line 209 of file SyncPacketQueue.h.

Member Function Documentation

◆ countNotEmpty()

template<unsigned int pktLen, unsigned int pktNum>
size_t Boardcore::SyncPacketQueue< pktLen, pktNum >::countNotEmpty ( )
inline
Returns
The number of packets in use, that are either fully or partially filled.

Definition at line 344 of file SyncPacketQueue.h.

◆ countReady()

template<unsigned int pktLen, unsigned int pktNum>
size_t Boardcore::SyncPacketQueue< pktLen, pktNum >::countReady ( )
inline
Returns
The number of packets that are ready to be sent.

Definition at line 325 of file SyncPacketQueue.h.

◆ get()

template<unsigned int pktLen, unsigned int pktNum>
const Packet< pktLen > Boardcore::SyncPacketQueue< pktLen, pktNum >::get ( )
inline
Returns
The oldest packet, without removing it from the queue.

Definition at line 273 of file SyncPacketQueue.h.

◆ isEmpty()

template<unsigned int pktLen, unsigned int pktNum>
bool Boardcore::SyncPacketQueue< pktLen, pktNum >::isEmpty ( )
inline
Returns
True if all the packets are completely empty.

Definition at line 304 of file SyncPacketQueue.h.

◆ isFull()

template<unsigned int pktLen, unsigned int pktNum>
bool Boardcore::SyncPacketQueue< pktLen, pktNum >::isFull ( )
inline
Returns
True if all the packets have been marked as ready.

Definition at line 291 of file SyncPacketQueue.h.

◆ pop()

template<unsigned int pktLen, unsigned int pktNum>
const Packet< pktLen > Boardcore::SyncPacketQueue< pktLen, pktNum >::pop ( )
inline
Returns
The oldest packet, removing it from the queue.

Definition at line 282 of file SyncPacketQueue.h.

◆ put()

template<unsigned int pktLen, unsigned int pktNum>
bool Boardcore::SyncPacketQueue< pktLen, pktNum >::put ( uint8_t * msg,
size_t msgLen )
inline

Try to append a given message to the packets queue.

The message is appended to the last packet and if the space isn't enough, it is divided into successive packets. If there are no more available packets, the oldest one is overwritten.

The message isn't added to the queue only if there is no space considering all the queue packets.

Parameters
msgThe message to be appended.
msgLenLength of the message [bytes].
Returns
True if the message was appended.

Definition at line 226 of file SyncPacketQueue.h.

◆ waitUntilNotEmpty()

template<unsigned int pktLen, unsigned int pktNum>
void Boardcore::SyncPacketQueue< pktLen, pktNum >::waitUntilNotEmpty ( )
inline

Blocks the calling thread until the queue is not empty.

Returns immediately if already not empty.

Definition at line 315 of file SyncPacketQueue.h.


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