From b8dd8d973dc29063c7c2ae2fa52386ebb215aecb Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Sat, 13 Feb 2010 16:50:08 +0000 Subject: What the HELL was I thinking? Apparently ItoAtom was never used, and it's so handy too... It wasn't in the right namespace, it was broken, it had pieces that were misnamed...bleh...anyway, it complies and works now. --- src/itoatom.h | 81 ++++++++++++++++++++++++++++++----------------------------- 1 file changed, 41 insertions(+), 40 deletions(-) (limited to 'src') diff --git a/src/itoatom.h b/src/itoatom.h index 2791519..5d4db0e 100644 --- a/src/itoatom.h +++ b/src/itoatom.h @@ -5,59 +5,60 @@ * terms of the license contained in the file LICENSE. */ -#ifndef BU_ITO_QUEUE_H -#define BU_ITO_QUEUE_H +#ifndef BU_ITO_ATOM_H +#define BU_ITO_ATOM_H #include #include "itomutex.h" #include "itocondition.h" -/** - * A thread-safe wrapper class. - *@ingroup Threading - */ -template -class ItoAtom +namespace Bu { -public: /** - * Construct an empty queue. + * A thread-safe wrapper class. + *@ingroup Threading */ - ItoAtom() + template + class ItoAtom { - } + public: + /** + * Construct an empty queue. + */ + ItoAtom() + { + } - ItoAtom( const T &src ) : - data( src ) - { - } - - ~ItoQueue() - { - } + ItoAtom( const T &src ) : + data( src ) + { + } + + ~ItoAtom() + { + } - T get() - { - mOperate.lock(); - mOperate.unlock(); - return data; - } + T get() + { + mOperate.lock(); + T ret = data; + mOperate.unlock(); + return ret; + } - void set( const T &val ) - { - mOperate.lock(); - data = val; - cBlock.signal(); - mOperate.unlock(); - } - -private: - Item *pStart; /**< The start of the queue, the next element to dequeue. */ - Item *pEnd; /**< The end of the queue, the last element to dequeue. */ - - ItoMutex mOperate; /**< The master mutex, used on all operations. */ - ItoCondition cBlock; /**< The condition for blocking dequeues. */ + void set( const T &val ) + { + mOperate.lock(); + data = val; + mOperate.unlock(); + } + + private: + T data; + + ItoMutex mOperate; /**< The master mutex, used on all operations. */ + }; }; #endif -- cgit v1.2.3