|
From: <bo...@us...> - 2009-03-28 01:48:43
|
Revision: 387
http://gearbox.svn.sourceforge.net/gearbox/?rev=387&view=rev
Author: borax00
Date: 2009-03-28 01:44:55 +0000 (Sat, 28 Mar 2009)
Log Message:
-----------
made naming of buffer functions more intuitive
Modified Paths:
--------------
gearbox/trunk/doc/history.dox
gearbox/trunk/src/gbxsickacfr/gbxiceutilacfr/buffer.h
gearbox/trunk/src/gbxsickacfr/gbxiceutilacfr/test/buffertest.cpp
gearbox/trunk/src/gbxsickacfr/serialhandler.h
Modified: gearbox/trunk/doc/history.dox
===================================================================
--- gearbox/trunk/doc/history.dox 2009-03-02 08:11:52 UTC (rev 386)
+++ gearbox/trunk/doc/history.dox 2009-03-28 01:44:55 UTC (rev 387)
@@ -29,7 +29,10 @@
@par Updated libraries
+- libGbxIceUtilAcfr:
+ - Changed names in buffer.h to make it more intuitive, fixed comments (AlexB).
+
@section gbx_doc_history_902 Changes in Release 9.02
@par New libraries
Modified: gearbox/trunk/src/gbxsickacfr/gbxiceutilacfr/buffer.h
===================================================================
--- gearbox/trunk/src/gbxsickacfr/gbxiceutilacfr/buffer.h 2009-03-02 08:11:52 UTC (rev 386)
+++ gearbox/trunk/src/gbxsickacfr/gbxiceutilacfr/buffer.h 2009-03-28 01:44:55 UTC (rev 387)
@@ -38,26 +38,6 @@
this container for storing smart pointers (e.g. IceUtil smart pointers). In this case the container will
only store the pointers and will not perform a deep copy.
-You should always try to @ref get() data before blocking with @ref getNext() because closely spaced push events may be lost. For example:
-@verbatim
-gbxiceutilacfr::Buffer<double> buffer( 10, gbxiceutilacfr::BufferTypeCircular );
-double data;
-while (1)
-{
- int ret = 0;
- try {
- buffer.getAndPop( data );
- }
- catch ( const gbxutilacfr::Exception & e ) {
- ret = buffer.getAndPopNext( data, TIMEOUT_MS );
- }
- if ( ret == 0 )
- {
- // do something with data
- }
-}
-@endverbatim
-
@note This implementation uses IceUtil threading classes. See example in sec. 28.9.2 of the Ice manual.
@see Notify, Proxy
*/
@@ -133,20 +113,20 @@
/*!
* If there is an object in the buffer, sets the object and returns 0;
*
- * If the buffer is empty, @ref getNext() blocks until a new object is pushed in
- * and returns the new value. By default, there is no timeout (negative value).
+ * If the buffer is empty, @ref getWithTimeout() blocks until a new object is pushed in
+ * and returns the new value. By default, there is an infinite timeout (negative value).
* Returns 0 if successful.
*
* If timeout is set to a positive value and the wait times out, this function returns -1
* and the object argument itself is not touched. In the rare event of spurious wakeup,
* the return value is 1.
*/
- int getNext( Type & obj, int timeoutMs=-1 );
+ int getWithTimeout( Type & obj, int timeoutMs=-1 );
/*!
- * Same as @ref getNext but calls @ref pop afterwards.
+ * Same as @ref getWithTimeout but calls @ref pop afterwards.
*/
- int getAndPopNext( Type & obj, int timeoutMs=-1 );
+ int getAndPopWithTimeout( Type & obj, int timeoutMs=-1 );
protected:
@@ -173,8 +153,8 @@
// buffer type (see type definitions in BufferType enum)
BufferType type_;
- // internal implementation of front( obj, -1 ); returns 0.
- int getNextNoWait( Type & obj );
+ // internal implementation of getWithTimeout( obj, -1 );
+ void getWithInfiniteWait( Type & obj );
};
@@ -298,12 +278,13 @@
}
template<class Type>
-int Buffer<Type>::getNext( Type &obj, int timeoutMs )
+int Buffer<Type>::getWithTimeout( Type &obj, int timeoutMs )
{
// special case: infinite wait time
if ( timeoutMs == -1 )
{
- return getNextNoWait( obj );
+ getWithInfiniteWait( obj );
+ return 0;
}
// finite wait time
@@ -339,9 +320,9 @@
}
template<class Type>
-int Buffer<Type>::getAndPopNext( Type &obj, int timeoutMs )
+int Buffer<Type>::getAndPopWithTimeout( Type &obj, int timeoutMs )
{
- int ret = getNext( obj, timeoutMs );
+ int ret = getWithTimeout( obj, timeoutMs );
if ( ret==0 ) {
pop();
}
@@ -350,7 +331,7 @@
// internal utility function (waits for update infinitely)
template<class Type>
-int Buffer<Type>::getNextNoWait( Type &obj )
+void Buffer<Type>::getWithInfiniteWait( Type &obj )
{
IceUtil::Monitor<IceUtil::Mutex>::Lock lock(*this);
@@ -362,7 +343,6 @@
}
internalGet( obj );
- return 0;
}
// NOTE: see notes on efficient notification in Ice sec. 28.9.3
Modified: gearbox/trunk/src/gbxsickacfr/gbxiceutilacfr/test/buffertest.cpp
===================================================================
--- gearbox/trunk/src/gbxsickacfr/gbxiceutilacfr/test/buffertest.cpp 2009-03-02 08:11:52 UTC (rev 386)
+++ gearbox/trunk/src/gbxsickacfr/gbxiceutilacfr/test/buffertest.cpp 2009-03-28 01:44:55 UTC (rev 387)
@@ -54,15 +54,15 @@
}
cout<<"ok"<<endl;
- cout<<"testing getNext() with empty buffer ... ";
- if ( buffer.getNext( data, 50 )==0 ) {
+ cout<<"testing getWithTimeout() with empty buffer ... ";
+ if ( buffer.getWithTimeout( data, 50 )==0 ) {
cout<<"failed. not expecting anybody setting the buffer"<<endl;
return EXIT_FAILURE;
}
cout<<"ok"<<endl;
- cout<<"testing getAndPopNext() with empty buffer ... ";
- if ( buffer.getAndPopNext( data, 50 )==0 ) {
+ cout<<"testing getAndPopWithTimeout() with empty buffer ... ";
+ if ( buffer.getAndPopWithTimeout( data, 50 )==0 ) {
cout<<"failed. not expecting anybody setting the proxy"<<endl;
return EXIT_FAILURE;
}
@@ -188,15 +188,15 @@
// todo: test where the last data actually went.
cout<<"ok"<<endl;
- cout<<"testing getNext() ... ";
- if ( buffer.getNext( data, 50 )!=0 ) {
+ cout<<"testing getWithTimeout() ... ";
+ if ( buffer.getWithTimeout( data, 50 )!=0 ) {
cout<<"failed. expected to get data"<<endl;
return EXIT_FAILURE;
}
cout<<"ok"<<endl;
- cout<<"testing getAndPopNext() ... ";
- if ( buffer.getAndPopNext( data, 50 )!=0 ) {
+ cout<<"testing getAndPopWithTimeout() ... ";
+ if ( buffer.getAndPopWithTimeout( data, 50 )!=0 ) {
cout<<"failed. expected to get data"<<endl;
return EXIT_FAILURE;
}
Modified: gearbox/trunk/src/gbxsickacfr/serialhandler.h
===================================================================
--- gearbox/trunk/src/gbxsickacfr/serialhandler.h 2009-03-02 08:11:52 UTC (rev 386)
+++ gearbox/trunk/src/gbxsickacfr/serialhandler.h 2009-03-28 01:44:55 UTC (rev 387)
@@ -83,7 +83,7 @@
int getNextResponse( TimedLmsResponse &timedResponse, int maxWaitMs )
{
gbxserialdeviceacfr::TimedResponse genericTimedResponse;
- int ret = serialDeviceHandler_->responseBuffer().getAndPopNext( genericTimedResponse, maxWaitMs );
+ int ret = serialDeviceHandler_->responseBuffer().getAndPopWithTimeout( genericTimedResponse, maxWaitMs );
if ( ret == 0 )
{
timedResponse.timeStampSec = genericTimedResponse.timeStampSec;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|