22 #ifndef __PL_WXWIDGETS_COMMS__
23 #define __PL_WXWIDGETS_COMMS__
32 #include <semaphore.h>
50 #ifdef PL_WXWIDGETS_IPC3
51 const unsigned char transmissionFlush = 10;
54 #define TEXTSIZEINFO_MAX_LENGTH 500
76 #ifdef PL_WXWIDGETS_IPC3
77 size_t plbufAmountToTransmit;
78 unsigned char transmissionType;
87 #ifdef PL_WXWIDGETS_IPC3
95 #define PL_SHARED_ARRAY_SIZE 10 * 1024
108 char data[PL_SHARED_ARRAY_SIZE];
111 class PLThreeSemaphores
123 void initializeToValid(
const char * baseName );
125 ~PLThreeSemaphores();
130 void initializeToInvalid();
131 bool isWriteSemaphoreValid();
132 bool isReadSemaphoreValid();
133 bool isTransmitSemaphoreValid();
137 bool areSemaphoresValid();
139 bool areWriteReadSemaphoresBlocked();
142 int getValueWriteSemaphore();
144 int getValueReadSemaphore();
145 #endif // #ifndef WIN32
146 void postWriteSemaphore();
147 void postReadSemaphore();
148 void postTransmitSemaphore();
149 void waitWriteSemaphore();
150 void waitReadSemaphore();
151 void waitTransmitSemaphore();
161 #define PL_SEMAPHORE_NAME_LENGTH 250 // Maximum length excluding terminating NULL byte
162 char m_wsemName[PL_SEMAPHORE_NAME_LENGTH + 1];
163 char m_rsemName[PL_SEMAPHORE_NAME_LENGTH + 1];
164 char m_tsemName[PL_SEMAPHORE_NAME_LENGTH + 1];
170 #else // #ifdef WIN32
175 #endif // #ifdef WIN32
178 #endif //#ifdef PL_WXWIDGETS_IPC3
187 void create(
const char *name,
PLINT size,
bool mustExist,
bool mustNotExist );
191 #ifdef PL_WXWIDGETS_IPC3
194 void initializeSemaphoresToValid(
const char *baseName ) { m_threeSemaphores.initializeToValid( baseName ); }
195 size_t *getTotalDataBytes() {
return &( ( (shmbuf *)
m_buffer )->nbytes ); }
196 size_t getSize() {
return PL_SHARED_ARRAY_SIZE; }
197 void transmitBytes(
bool ifHeader,
const void *src,
size_t n );
198 void receiveBytes(
bool ifHeader,
void *dest,
size_t n );
199 #else // #ifdef PL_WXWIDGETS_IPC3
202 #endif // #ifdef PL_WXWIDGETS_IPC3
210 #ifdef PL_WXWIDGETS_IPC3
213 PLThreeSemaphores m_threeSemaphores;
220 #ifndef PL_WXWIDGETS_IPC3
227 PLNamedMutex(
const char *name,
bool aquireOnCreate =
false );
228 void create(
const char *name,
bool aquireOnCreate =
false );
231 bool aquire(
unsigned long millisecs );
257 #endif //ifndef PL_WXWIDGETS_IPC3
void create(const char *name, bool aquireOnCreate=false)
PLNamedMutexLocker & operator=(const PLNamedMutex &)
wchar_t text[TEXTSIZEINFO_MAX_LENGTH+1]
void create(const char *name, PLINT size, bool mustExist, bool mustNotExist)