00001 // only compile if USE_SHMEMDEV is defined 00002 #ifdef USE_SHMEMDEV 00003 00004 // this code only works on linux 00005 #ifdef linux 00006 00007 #ifndef __CLUSTEREVENTBUFFER_H__ 00008 #define __CLUSTEREVENTBUFFER_H__ 00009 00024 class IPC_SimpleSemaphore; 00025 class SimpleSHMEM; 00026 00027 #include "ipc.simple.sem.H" 00028 #include "ipc.simple.shmem.H" 00029 00030 namespace IS3D { 00031 00032 class ClusterEventBuffer 00033 { 00034 public: 00035 enum { TERM_FLAG = 0, RENDERER_ATTACHED_FLAG, SHMEM_NUM_FLAGS }; 00036 00039 virtual bool init() = 0; 00040 00041 void setRenderingAttached(); 00042 bool hasRenderingAttached(); 00043 bool isRenderingAttached(); 00044 void lockBuffer(); 00045 void unlockBuffer(); 00046 char* getBuffer(); 00047 int getBufferSize(); 00048 void clearBuffer(); 00049 00050 protected: 00051 00052 void setFlag( int flag, bool val ); 00053 bool getFlag( int flag ); 00054 00055 int shmemTotalSize(); 00056 int shmemDeviceSize(); 00057 int shmemFlagsSize(); 00058 char* shmemDataAddr(); 00059 char* shmemFlagsAddr(); 00060 00061 00062 SimpleSHMEM *_buffer; 00063 IPC_SimpleSemaphore *_bufferGate; 00064 00065 public: 00066 static const int BUFFER_SIZE = 102400; // 100k should be way too much 00067 static const int SHORT_SLEEP = 5000; // 5 ms if this is in microseconds 00068 00069 }; 00070 00071 } 00072 00073 #endif 00074 00075 #endif 00076 00077 #endif