An implementation of a circular array allowing direct write and read.
CircularArray.h
- Committer:
- GLemasson
- Date:
- 2014-02-11
- Revision:
- 0:28766f5a758e
- Child:
- 1:5036a532fe62
File content as of revision 0:28766f5a758e:
#ifndef _CIRCULAR_ARRAY_H_ #define _CIRCULAR_ARRAY_H_ template<typename T> class CircularArray { private: unsigned int m_capacity; volatile unsigned int w; volatile unsigned int r; volatile bool m_full; volatile bool m_empty; volatile T * data; public: CircularArray(unsigned int capacity); ~CircularArray(); T * getWritePointer(); T * getReadPointer(T * buffer=0,unsigned int num=0); void writeElements(unsigned int num); void readElements(unsigned int num); unsigned int fillCapacity(); unsigned int freeSpace(); unsigned int size(); unsigned int readable(); bool full(); bool empty(); }; #endif