From ec05778d5718a7912e506764d443a78d6a6179e3 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Mon, 5 Nov 2012 22:41:51 +0000 Subject: Converted tabs to spaces with tabconv. --- src/stable/synchroheap.h | 262 +++++++++++++++++++++++------------------------ 1 file changed, 131 insertions(+), 131 deletions(-) (limited to 'src/stable/synchroheap.h') diff --git a/src/stable/synchroheap.h b/src/stable/synchroheap.h index 9448625..f5216bf 100644 --- a/src/stable/synchroheap.h +++ b/src/stable/synchroheap.h @@ -14,137 +14,137 @@ namespace Bu { - template, - typename itemalloc=std::allocator > - class SynchroHeap - { - public: - SynchroHeap() - { - } - - virtual ~SynchroHeap() - { - } - - void enqueue( item i ) - { - imData.lock(); - hData.enqueue( i ); - icBlock.signal(); - imData.unlock(); - } - - item dequeue( bool bBlock=false ) - { - imData.lock(); - if( hData.isEmpty() ) - { - imData.unlock(); - - if( bBlock ) - { - icBlock.lock(); - - while( hData.isEmpty() ) - icBlock.wait(); - - imData.lock(); - try - { - item iRet = hData.dequeue(); - imData.unlock(); - icBlock.unlock(); - return iRet; - } - catch(...) - { - imData.unlock(); - icBlock.unlock(); - throw; - } - } - throw HeapException("Heap empty."); - } - else - { - try - { - item iRet = hData.dequeue(); - imData.unlock(); - return iRet; - } - catch(...) - { - imData.unlock(); - throw; - } - } - } - - item dequeue( int iSec, int iUSec ) - { - imData.lock(); - if( hData.isEmpty() ) - { - imData.unlock(); - - icBlock.lock(); - - icBlock.wait( iSec, iUSec ); - - imData.lock(); - try - { - item iRet = hData.dequeue(); - imData.unlock(); - icBlock.unlock(); - return iRet; - } - catch(...) - { - imData.unlock(); - icBlock.unlock(); - throw; - } - } - else - { - try - { - item iRet = hData.dequeue(); - imData.unlock(); - return iRet; - } - catch(...) - { - imData.unlock(); - throw; - } - } - } - - bool isEmpty() - { - imData.lock(); - bool bRet = hData.isEmpty(); - imData.unlock(); - return bRet; - } - - int getSize() - { - imData.lock(); - int iRet = hData.getSize(); - imData.unlock(); - return iRet; - } - - private: - Heap< item, cmpfunc, itemalloc > hData; - Mutex imData; - Condition icBlock; - }; + template, + typename itemalloc=std::allocator > + class SynchroHeap + { + public: + SynchroHeap() + { + } + + virtual ~SynchroHeap() + { + } + + void enqueue( item i ) + { + imData.lock(); + hData.enqueue( i ); + icBlock.signal(); + imData.unlock(); + } + + item dequeue( bool bBlock=false ) + { + imData.lock(); + if( hData.isEmpty() ) + { + imData.unlock(); + + if( bBlock ) + { + icBlock.lock(); + + while( hData.isEmpty() ) + icBlock.wait(); + + imData.lock(); + try + { + item iRet = hData.dequeue(); + imData.unlock(); + icBlock.unlock(); + return iRet; + } + catch(...) + { + imData.unlock(); + icBlock.unlock(); + throw; + } + } + throw HeapException("Heap empty."); + } + else + { + try + { + item iRet = hData.dequeue(); + imData.unlock(); + return iRet; + } + catch(...) + { + imData.unlock(); + throw; + } + } + } + + item dequeue( int iSec, int iUSec ) + { + imData.lock(); + if( hData.isEmpty() ) + { + imData.unlock(); + + icBlock.lock(); + + icBlock.wait( iSec, iUSec ); + + imData.lock(); + try + { + item iRet = hData.dequeue(); + imData.unlock(); + icBlock.unlock(); + return iRet; + } + catch(...) + { + imData.unlock(); + icBlock.unlock(); + throw; + } + } + else + { + try + { + item iRet = hData.dequeue(); + imData.unlock(); + return iRet; + } + catch(...) + { + imData.unlock(); + throw; + } + } + } + + bool isEmpty() + { + imData.lock(); + bool bRet = hData.isEmpty(); + imData.unlock(); + return bRet; + } + + int getSize() + { + imData.lock(); + int iRet = hData.getSize(); + imData.unlock(); + return iRet; + } + + private: + Heap< item, cmpfunc, itemalloc > hData; + Mutex imData; + Condition icBlock; + }; }; #endif -- cgit v1.2.3