|

INTRODUCTION
Overview
Download and Install
Documentation
Publications
REPOSITORY
Libraries
DEVELOPER
Dev Guide
Dashboard
PEOPLE
Contributors
Users

Project
Download
Mailing lists
|
|
|
11#ifndef GBXICEUTILACFR_BUFFER_H
12#define GBXICEUTILACFR_BUFFER_H
15#include <gbxutilacfr/exceptions.h>
17#include <IceUtil/Monitor.h>
18#include <IceUtil/Mutex.h>
19#include <IceUtil/Time.h>
45class Buffer : public IceUtil::Monitor<IceUtil::Mutex>
86 void push( const Type & obj );
100 void get( Type & obj ) const;
106 void get( Type & obj, unsigned int n ) const;
134 std::deque<Type> queue_;
137 virtual void internalGet( Type & obj ) const ;
140 virtual void internalGet( Type & obj, unsigned int n ) const ;
143 virtual void internalPush( const Type & obj );
157 void getWithInfiniteWait( Type & obj );
173Buffer<Type>::~Buffer()
183 IceUtil::Monitor<IceUtil::Mutex>::Lock lock(* this);
192 IceUtil::Monitor<IceUtil::Mutex>::Lock lock(* this);
200 IceUtil::Monitor<IceUtil::Mutex>::Lock lock(* this);
207 IceUtil::Monitor<IceUtil::Mutex>::Lock lock(* this);
214 IceUtil::Monitor<IceUtil::Mutex>::Lock lock(* this);
215 return queue_.empty();
221 IceUtil::Monitor<IceUtil::Mutex>::Lock lock(* this);
222 return queue_.size();
228 IceUtil::Monitor<IceUtil::Mutex>::Lock lock(* this);
229 if ( queue_.empty() ) {
239 IceUtil::Monitor<IceUtil::Mutex>::Lock lock(* this);
240 if ( !queue_.empty() )
253 IceUtil::Monitor<IceUtil::Mutex>::Lock lock(* this);
254 if ( queue_.empty() ){
257 else if( n >= queue_.size()){
261 internalGet( obj ,n );
268 IceUtil::Monitor<IceUtil::Mutex>::Lock lock(* this);
269 if ( !queue_.empty() )
284 if ( timeoutMs == -1 )
286 getWithInfiniteWait( obj );
291 IceUtil::Monitor<IceUtil::Mutex>::Lock lock(* this);
294 if ( !queue_.empty() )
302 if ( this->timedWait( IceUtil::Time::milliSeconds( timeoutMs ) ) )
306 if ( !queue_.empty() )
334void Buffer<Type>::getWithInfiniteWait( Type &obj )
336 IceUtil::Monitor<IceUtil::Mutex>::Lock lock(* this);
340 while ( queue_.empty() )
352 IceUtil::Monitor<IceUtil::Mutex>::Lock lock(* this);
355 if ( ( int)queue_.size() < depth_ || depth_<0 )
376void Buffer<Type>::internalGet( Type & obj ) const
378 obj = queue_.front();
382void Buffer<Type>::internalGet( Type & obj, unsigned int n ) const
388void Buffer<Type>::internalPush( const Type & obj )
390 queue_.push_back( obj );
void purge() Deletes all entries, makes the buffer empty. Definition buffer.h:205
void configure(int depth, BufferType type=BufferTypeCircular) Definition buffer.h:178
BufferType type() const Definition buffer.h:198
Buffer(int depth=-1, BufferType type=BufferTypeQueue) Definition buffer.h:165
int depth() const Definition buffer.h:190
int size() const Returns the number of items in the buffer. Definition buffer.h:219
void pop() Definition buffer.h:226
int getAndPopWithTimeout(Type &obj, int timeoutMs=-1) Definition buffer.h:323
void push(const Type &obj) Definition buffer.h:350
bool isEmpty() const Returns FALSE if there's something in the buffer. Definition buffer.h:212
void get(Type &obj) const Definition buffer.h:237
void getAndPop(Type &obj) Definition buffer.h:266
int getWithTimeout(Type &obj, int timeoutMs=-1) Definition buffer.h:281
void get(Type &obj, unsigned int n) const Definition buffer.h:251
Base class for all GbxUtilAcfr exceptions. Definition gbxutilacfr/exceptions.h:66
Utility namespace (part of SICK-ACFR driver) Definition buffer.h:21
BufferType Buffer type defines behavior when the buffer is full Definition buffer.h:25
@ BufferTypeCircular Definition buffer.h:28
@ BufferTypeQueue Definition buffer.h:31
|
|