18 #ifndef LUNCHBOX_LFQUEUE_H
19 #define LUNCHBOX_LFQUEUE_H
21 #include <lunchbox/atomic.h>
22 #include <lunchbox/debug.h>
23 #include <lunchbox/nonCopyable.h>
24 #include <lunchbox/thread.h>
49 : _data( size + 1 ), _readPos( 0 ), _writePos( 0 ) {}
55 bool isEmpty()
const {
return _readPos == _writePos; }
60 LB_TS_SCOPED( _reader );
76 _data.resize( size + 1 );
89 LB_TS_SCOPED( _reader );
90 if( _readPos == _writePos )
93 result = _data[ _readPos ];
94 _readPos = (_readPos + 1) % _data.size();
108 LB_TS_SCOPED( _reader );
109 if( _readPos == _writePos )
112 result = _data[ _readPos ];
125 LB_TS_SCOPED( _writer );
126 int32_t nextPos = (_writePos + 1) % _data.size();
127 if( nextPos == _readPos )
130 _data[ _writePos ] = element;
142 std::vector< T > _data;
146 LB_TS_VAR( _reader );
147 LB_TS_VAR( _writer );
150 #endif // LUNCHBOX_LFQUEUE_H