F´ Flight Software - C/C++ Documentation  devel
A framework for building embedded system applications to NASA flight quality standards.
PriorityQueue.hpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title Os/Generic/PriorityQueue.hpp
3 // \brief priority queue implementation definitions for Os::Queue
4 // ======================================================================
5 #include "Os/Condition.hpp"
7 #include "Os/Mutex.hpp"
8 #include "Os/Queue.hpp"
9 #ifndef OS_GENERIC_PRIORITYQUEUE_HPP
10 #define OS_GENERIC_PRIORITYQUEUE_HPP
11 
12 namespace Os {
13 namespace Generic {
14 
23  U8* m_data = nullptr;
24  FwSizeType* m_indices = nullptr;
25  FwSizeType* m_sizes = nullptr;
34 
37 
40  void return_index(FwSizeType index);
41 
43  void store_data(FwSizeType index, const U8* source, FwSizeType size);
44 
46  void load_data(FwSizeType index, U8* destination, FwSizeType capacity);
47 };
55  public:
57  PriorityQueue() = default;
58 
60  virtual ~PriorityQueue();
61 
63  PriorityQueue(const QueueInterface& other) = delete;
64 
66  PriorityQueue(const QueueInterface* other) = delete;
67 
69  PriorityQueue& operator=(const QueueInterface& other) override = delete;
70 
81  Status create(const Fw::StringBase& name, FwSizeType depth, FwSizeType messageSize) override;
82 
97  Status send(const U8* buffer, FwSizeType size, FwQueuePriorityType priority, BlockingType blockType) override;
98 
114  Status receive(U8* destination,
115  FwSizeType capacity,
116  BlockingType blockType,
117  FwSizeType& actualSize,
118  FwQueuePriorityType& priority) override;
119 
123  FwSizeType getMessagesAvailable() const override;
124 
130  FwSizeType getMessageHighWaterMark() const override;
131 
132  QueueHandle* getHandle() override;
133 
135 };
136 } // namespace Generic
137 } // namespace Os
138 
139 #endif // OS_GENERIC_PRIORITYQUEUE_HPP
uint8_t U8
8-bit unsigned integer
Definition: BasicTypes.h:30
PlatformSizeType FwSizeType
Definition: FpConfig.h:35
PlatformQueuePriorityType FwQueuePriorityType
Definition: FpConfig.h:55
condition variable implementation
Definition: Condition.hpp:66
generic priority queue implementation
PriorityQueue()=default
default queue interface constructor
PriorityQueue & operator=(const QueueInterface &other) override=delete
assignment operator is forbidden
Status receive(U8 *destination, FwSizeType capacity, BlockingType blockType, FwSizeType &actualSize, FwQueuePriorityType &priority) override
receive a message from the queue
Status send(const U8 *buffer, FwSizeType size, FwQueuePriorityType priority, BlockingType blockType) override
send a message into the queue
PriorityQueue(const QueueInterface *other)=delete
copy constructor is forbidden
virtual ~PriorityQueue()
default queue destructor
PriorityQueueHandle m_handle
Status create(const Fw::StringBase &name, FwSizeType depth, FwSizeType messageSize) override
create queue storage
FwSizeType getMessagesAvailable() const override
get number of messages available
PriorityQueue(const QueueInterface &other)=delete
copy constructor is forbidden
FwSizeType getMessageHighWaterMark() const override
get maximum messages stored at any given time
QueueHandle * getHandle() override
return the underlying queue handle (implementation specific)
QueueHandle parent class.
Definition: Queue.hpp:19
base queue interface
Definition: Queue.hpp:27
BlockingType
message type
Definition: Queue.hpp:44
Status
status returned from the queue send function
Definition: Queue.hpp:30
A stable max heap data structure.
Definition: MaxHeap.hpp:28
critical data stored for priority queue
Os::Mutex m_data_lock
Lock against data manipulation.
void store_data(FwSizeType index, const U8 *source, FwSizeType size)
store data into a set index in the data store
FwSizeType m_startIndex
Start index of the circular data structure.
void load_data(FwSizeType index, U8 *destination, FwSizeType capacity)
load data from a set index in the data store
void return_index(FwSizeType index)
return index to the circular data structure
FwSizeType * m_sizes
Size store for each method.
FwSizeType m_maxSize
Maximum size allowed of a message.
FwSizeType find_index()
find an available index to store data from the list
Types::MaxHeap m_heap
MaxHeap data store for tracking priority.
FwSizeType * m_indices
List of indices into data.
Os::ConditionVariable m_empty
Queue empty condition variable to support blocking.
FwSizeType m_stopIndex
End index of the circular data structure.
U8 * m_data
Pointer to data allocation.
FwSizeType m_depth
Depth of the queue.
FwSizeType m_highMark
Message count high water mark.
Os::ConditionVariable m_full
Queue full condition variable to support blocking.