#ifndef __VirtualRingBuffer_H__ #define __VirtualRingBuffer_H__ #include #include #include class VirtualRingBuffer { public: void *buffer; void *bufferEnd; unsigned long bufferLength; // buffer is the start of the ring buffer's address space. // bufferEnd is the end of the "real" buffer (always buffer + bufferLength). // Note that the "virtual" portion of the buffer extends from bufferEnd to bufferEnd+bufferLength. void *readPointer; void *writePointer; mach_port_t memoryEntry; VirtualRingBuffer(unsigned long); ~VirtualRingBuffer(void); void clear(void); void empty(void); unsigned char isEmpty(void); unsigned long lengthAvailableToReadReturningPointer(void**); void didReadLength(unsigned long); unsigned long lengthAvailableToWriteReturningPointer(void**); void didWriteLength(unsigned long); private: static void *allocateVirtualBuffer(unsigned long, mach_port_t*); static void deallocateVirtualBuffer(void*, unsigned long); }; #endif //__VirtualRingBuffer_H__