1 #ifndef GMMANAGEDARRAYRINGBUFFER_HPP_
2 #define GMMANAGEDARRAYRINGBUFFER_HPP_
5 #include <ti/sysbios/knl/Semaphore.h>
8 #include "GmArrayRingBuffer.hpp"
18 template <
typename T,
int C>
27 int WriteRecord (T *pcSource) ;
28 int ReadRecord (T *pcDestination) ;
32 pthread_mutex_t m_mutex;
36 Semaphore_Handle mHasItemsSemaphore;
42 #ifndef _GEO_APPDEFS_HPP
43 #include <GeoAppDefs.hpp>
55 #include <xdc/cfg/global.h>
56 #include <xdc/runtime/Error.h>
57 #include <xdc/runtime/System.h>
58 #include <xdc/runtime/Memory.h>
59 #include <ti/sysbios/knl/Swi.h>
61 #include "geotypes.hpp"
63 #include "GmRingBuffer.hpp"
64 #include "GmArrayRingBuffer.hpp"
70 #ifdef DEBUGGING_COMPILE_ISSUES
75 template <
typename T,
int C>
80 mHasItemsSemaphore (hasItemsSemaphore)
83 int status = pthread_mutex_init (&m_mutex, NULL);
85 #ifdef DEBUGGING_COMPILE_ISSUES
87 WriteRecord (&aTestItem);
88 ReadRecord (&aTestItem);
92 template <
typename T,
int C>
96 pthread_mutex_destroy (&m_mutex);
104 template <
typename T,
int C>
111 gateKey = Swi_disable();
114 pthread_mutex_lock (&m_mutex);
117 if (this->IsEmpty ())
121 Swi_restore (gateKey);
124 pthread_mutex_unlock (&m_mutex);
126 return GM_RING_BUFFER_EMPTY;
130 iReadBuffer = this->m_iLastBufferRead + 1;
132 if (iReadBuffer == this->MaxSize())
135 if (pcDestination !=
nullptr)
137 *pcDestination = this->GetBuffer (iReadBuffer);
141 this->m_bNextWriteWouldOverrun = FALSE;
144 this->m_iLastBufferRead = iReadBuffer;
149 Swi_restore (gateKey);
152 pthread_mutex_unlock (&m_mutex);
155 if (pcDestination ==
nullptr)
156 return GM_RING_BUFFER_NULL_DESTINATION;
158 return GM_RING_BUFFER_OK;
162 template <
typename T,
int C>
175 gateKey = Swi_disable();
178 pthread_mutex_lock (&m_mutex);
180 iTest = InternalWriteRecord (pcSource);
183 Swi_restore (gateKey);
189 Semaphore_post (mHasItemsSemaphore);
192 pthread_mutex_unlock (&m_mutex);
Definition: GmArrayRingBuffer.hpp:22
Definition: GmManagedArrayRingBuffer.hpp:20
GmApp/GmLoggingApp.hpp>
Definition: Analogs.hpp:47