PX4 Firmware
PX4 Autopilot Software http://px4.io
Queue< T > Class Template Reference

Generic queue based on the linked list class defined in libuavcan. More...

#include <uavcan_virtual_can_driver.hpp>

Collaboration diagram for Queue< T >:

Classes

struct  Item
 

Public Member Functions

 Queue (uavcan::IPoolAllocator &arg_allocator, std::size_t block_allocation_quota)
 
 ~Queue ()
 
bool isEmpty () const
 
template<typename... Args>
bool tryEmplace (Args... args)
 Creates one item in-place at the end of the list. More...
 
T * peek ()
 Accesses the first element. More...
 
const T * peek () const
 
void pop ()
 Removes the first element. More...
 

Private Attributes

uavcan::LimitedPoolAllocator allocator_
 
uavcan::LinkedListRoot< Itemlist_
 

Detailed Description

template<typename T>
class Queue< T >

Generic queue based on the linked list class defined in libuavcan.

This class does not use heap memory.

Definition at line 97 of file uavcan_virtual_can_driver.hpp.

Constructor & Destructor Documentation

◆ Queue()

template<typename T>
Queue< T >::Queue ( uavcan::IPoolAllocator &  arg_allocator,
std::size_t  block_allocation_quota 
)
inline

Definition at line 110 of file uavcan_virtual_can_driver.hpp.

◆ ~Queue()

template<typename T>
Queue< T >::~Queue ( )
inline

Definition at line 116 of file uavcan_virtual_can_driver.hpp.

Member Function Documentation

◆ isEmpty()

template<typename T>
bool Queue< T >::isEmpty ( ) const
inline

Definition at line 123 of file uavcan_virtual_can_driver.hpp.

Referenced by VirtualCanIface::addRxFrame(), VirtualCanIface::hasDataInRxQueue(), and VirtualCanIface::receive().

Here is the caller graph for this function:

◆ peek() [1/2]

template<typename T>
T* Queue< T >::peek ( )
inline

Accesses the first element.

Nullptr will be returned if the queue is empty. Complexity is O(1).

Definition at line 168 of file uavcan_virtual_can_driver.hpp.

Referenced by VirtualCanIface::receive().

Here is the caller graph for this function:

◆ peek() [2/2]

template<typename T>
const T* Queue< T >::peek ( ) const
inline

Definition at line 169 of file uavcan_virtual_can_driver.hpp.

◆ pop()

template<typename T>
void Queue< T >::pop ( )
inline

Removes the first element.

If the queue is empty, nothing will be done and assertion failure will be triggered. Complexity is O(1).

Definition at line 176 of file uavcan_virtual_can_driver.hpp.

Referenced by VirtualCanIface::addRxFrame(), and VirtualCanIface::receive().

Here is the caller graph for this function:

◆ tryEmplace()

template<typename T>
template<typename... Args>
bool Queue< T >::tryEmplace ( Args...  args)
inline

Creates one item in-place at the end of the list.

Returns true if the item was appended successfully, false if there's not enough memory. Complexity is O(N) where N is queue length.

Definition at line 131 of file uavcan_virtual_can_driver.hpp.

Referenced by VirtualCanIface::addRxFrame().

Here is the caller graph for this function:

Member Data Documentation

◆ allocator_

template<typename T>
uavcan::LimitedPoolAllocator Queue< T >::allocator_
private

Definition at line 106 of file uavcan_virtual_can_driver.hpp.

◆ list_

template<typename T>
uavcan::LinkedListRoot<Item> Queue< T >::list_
private

Definition at line 107 of file uavcan_virtual_can_driver.hpp.


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