F´ Flight Software - C/C++ Documentation  devel
A framework for building embedded system applications to NASA flight quality standards.
LocklessQueue.hpp
Go to the documentation of this file.
1 #ifndef _LOCKLESS_QUEUE_H_
2 #define _LOCKLESS_QUEUE_H_
3 
4 #include <FpConfig.hpp>
5 #include <Os/Queue.hpp>
6 #ifndef BUILD_DARWIN // Allow compiling
7 #include <mqueue.h>
8 #endif
9 
10 namespace Os {
11 
12  class LocklessQueue {
13 
14  typedef struct QueueNode_s {
15  U8 * data;
16  NATIVE_INT_TYPE size;
17  struct QueueNode_s * next;
18  } QueueNode;
19 
20  public:
21 
24 
25 #ifndef BUILD_DARWIN // Allow compiling
26  void GetAttr (mq_attr & attr);
27 #endif
28 
29  Os::Queue::QueueStatus Send (const U8 * buffer, NATIVE_INT_TYPE size);
31 
32  private:
33  bool PopFree (QueueNode ** free_node);
34  void PushFree (QueueNode * my_node);
35 
36  QueueNode * m_first;
37  QueueNode * m_last;
38 
39  QueueNode * m_free_head;
40 
41  QueueNode * m_index;
42  U8 * m_data;
43 #ifndef BUILD_DARWIN
44  mq_attr m_attr;
45 #endif
46  };
47 
48 }
49 
50 #endif
PlatformIntType NATIVE_INT_TYPE
Definition: BasicTypes.h:51
uint8_t U8
8-bit unsigned integer
Definition: BasicTypes.h:26
C++-compatible configuration header for fprime configuration.
Os::Queue::QueueStatus Receive(U8 *buffer, NATIVE_INT_TYPE capacity, NATIVE_INT_TYPE &size)
LocklessQueue(NATIVE_INT_TYPE maxmsg, NATIVE_INT_TYPE msgsize)
void GetAttr(mq_attr &attr)
Os::Queue::QueueStatus Send(const U8 *buffer, NATIVE_INT_TYPE size)
QueueStatus
Definition: Queue.hpp:27