Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
Gray::cQueueStatic< TYPE, _QTY > Class Template Reference

#include <cQueue.h>

Inheritance diagram for Gray::cQueueStatic< TYPE, _QTY >:
Gray::cQueueBase

Public Member Functions

 cQueueStatic () noexcept
 
bool isFullQ () const noexcept
 
void EmptyQ () noexcept
 
ITERATE_t get_ReadQtyT () const noexcept
 
ITERATE_t get_ReadQtyC () const noexcept
 
const TYPEget_ReadPtr () const
 
void AdvanceRead (ITERATE_t iCount=1)
 
ITERATE_t get_WriteQtyT () const noexcept
 
TYPE Read1 ()
 
ITERATE_t ReadQty (TYPE *pBuf, ITERATE_t nCountMax)
 
ITERATE_t ReadQtySafe (TYPE *pBuf, ITERATE_t nCountMax)
 
bool WriteQ (TYPE val)
 
HRESULT WriteQty (const TYPE *pVal, ITERATE_t iLength)
 
HRESULT WriteQtySafe (const TYPE *pVal, ITERATE_t iLength)
 
- Public Member Functions inherited from Gray::cQueueBase
 cQueueBase (ITERATE_t iReadLast=0, ITERATE_t iWriteLast=0) noexcept
 
void InitQ (ITERATE_t iReadLast=0, ITERATE_t iWriteLast=0) noexcept
 
bool isEmptyQ () const noexcept
 
void EmptyQ () noexcept
 
ITERATE_t get_ReadIndex () const noexcept
 
ITERATE_t get_WriteIndex () const noexcept
 
ITERATE_t get_ReadQty () const
 
void AdvanceRead (ITERATE_t iCount=1)
 
STREAM_SEEKRET_t SeekQ (STREAM_OFFSET_t iOffset, SEEK_ORIGIN_TYPE eSeekOrigin=SEEK_Set)
 

Public Attributes

TYPE m_Data [_QTY]
 

Protected Member Functions

ITERATE_t GetWrapIndex (ITERATE_t i) const noexcept
 

Additional Inherited Members

- Protected Attributes inherited from Gray::cQueueBase
ITERATE_t m_iReadLast
 old items removed/read from here. More...
 
ITERATE_t m_iWriteLast
 new items added/written here. end of read. More...
 

Detailed Description

template<class TYPE = BYTE, ITERATE_t _QTY = 1024>
class Gray::cQueueStatic< TYPE, _QTY >

Create a generic thread/multi process safe (static sized) wrapping queue. similar to std::istringstream except NOT on Heap. static allocations.

Note
Get and Put are NOT reentrant safe against themselves, just each other. m_iWriteLast and m_iReadLast will wrap to fill.

Constructor & Destructor Documentation

◆ cQueueStatic()

template<class TYPE = BYTE, ITERATE_t _QTY = 1024>
Gray::cQueueStatic< TYPE, _QTY >::cQueueStatic ( )
inlinenoexcept

Member Function Documentation

◆ AdvanceRead()

template<class TYPE = BYTE, ITERATE_t _QTY = 1024>
void Gray::cQueueStatic< TYPE, _QTY >::AdvanceRead ( ITERATE_t  iCount = 1)
inline

◆ EmptyQ()

template<class TYPE = BYTE, ITERATE_t _QTY = 1024>
void Gray::cQueueStatic< TYPE, _QTY >::EmptyQ ( )
inlinenoexcept

thread safe. single instruction operations cannot be time sliced.

Note
Should NOT be called by the Put thread !

◆ get_ReadPtr()

template<class TYPE = BYTE, ITERATE_t _QTY = 1024>
const TYPE* Gray::cQueueStatic< TYPE, _QTY >::get_ReadPtr ( ) const
inline

use get_ReadQtyC() to get the allowed size.

◆ get_ReadQtyC()

template<class TYPE = BYTE, ITERATE_t _QTY = 1024>
ITERATE_t Gray::cQueueStatic< TYPE, _QTY >::get_ReadQtyC ( ) const
inlinenoexcept

Max we can get in a single CONTIGUOUS block peek/read. For use with get_ReadPtr().

◆ get_ReadQtyT()

template<class TYPE = BYTE, ITERATE_t _QTY = 1024>
ITERATE_t Gray::cQueueStatic< TYPE, _QTY >::get_ReadQtyT ( ) const
inlinenoexcept

How much Total data is in the Queue ? may be wrapped. Thread safe.

◆ get_WriteQtyT()

template<class TYPE = BYTE, ITERATE_t _QTY = 1024>
ITERATE_t Gray::cQueueStatic< TYPE, _QTY >::get_WriteQtyT ( ) const
inlinenoexcept

total available space to write - not contiguous

Note
since read=write=empty we can only use QTY-1 to write.

◆ GetWrapIndex()

template<class TYPE = BYTE, ITERATE_t _QTY = 1024>
ITERATE_t Gray::cQueueStatic< TYPE, _QTY >::GetWrapIndex ( ITERATE_t  i) const
inlineprotectednoexcept

◆ isFullQ()

template<class TYPE = BYTE, ITERATE_t _QTY = 1024>
bool Gray::cQueueStatic< TYPE, _QTY >::isFullQ ( ) const
inlinenoexcept

◆ Read1()

template<class TYPE = BYTE, ITERATE_t _QTY = 1024>
TYPE Gray::cQueueStatic< TYPE, _QTY >::Read1 ( )
inline

Read a single TYPE element. Thread safe against Write.

Note
This is NOT reentrant safe. i.e. multi calls to Read().
ASSERT if empty!

◆ ReadQty()

template<class TYPE = BYTE, ITERATE_t _QTY = 1024>
ITERATE_t Gray::cQueueStatic< TYPE, _QTY >::ReadQty ( TYPE pBuf,
ITERATE_t  nCountMax 
)
inline

copy TYPE data out. NOT thread safe.

Todo:
use CopyElements?

◆ ReadQtySafe()

template<class TYPE = BYTE, ITERATE_t _QTY = 1024>
ITERATE_t Gray::cQueueStatic< TYPE, _QTY >::ReadQtySafe ( TYPE pBuf,
ITERATE_t  nCountMax 
)
inline

copy TYPE data out. Thread Safe against write.

◆ WriteQ()

template<class TYPE = BYTE, ITERATE_t _QTY = 1024>
bool Gray::cQueueStatic< TYPE, _QTY >::WriteQ ( TYPE  val)
inline

Add a single TYPE element. Thread Safe against Read.

Note
This is NOT reentrant safe. i.e. multi calls to Write()
Returns
false = full.

◆ WriteQty()

template<class TYPE = BYTE, ITERATE_t _QTY = 1024>
HRESULT Gray::cQueueStatic< TYPE, _QTY >::WriteQty ( const TYPE pVal,
ITERATE_t  iLength 
)
inline

Add several TYPE items to the Q using CopyElements. NOT thread safe.

Note
This is NOT reentrant/thread safe.
Returns
length put. 0 = full. I cant write anything.

◆ WriteQtySafe()

template<class TYPE = BYTE, ITERATE_t _QTY = 1024>
HRESULT Gray::cQueueStatic< TYPE, _QTY >::WriteQtySafe ( const TYPE pVal,
ITERATE_t  iLength 
)
inline

Thread Safe against Read.

Member Data Documentation

◆ m_Data

template<class TYPE = BYTE, ITERATE_t _QTY = 1024>
TYPE Gray::cQueueStatic< TYPE, _QTY >::m_Data[_QTY]

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