From aeb8bee786a9495c78ed94e2a8485ed790714635 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Sat, 1 May 2010 02:47:08 +0000 Subject: The cache... --- src/buffer.cpp | 9 +++++++-- src/buffer.h | 2 ++ src/cache.h | 27 +++++++++++++++------------ 3 files changed, 24 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/buffer.cpp b/src/buffer.cpp index 57f965c..cbebfc2 100644 --- a/src/buffer.cpp +++ b/src/buffer.cpp @@ -41,12 +41,12 @@ void Bu::Buffer::fillReadBuf() { if( iReadBufFill+iReadPos < iBufSize ) { - //printf("Buffer: Attempting to read %db.\n", iBufSize-iReadBufFill-iReadPos ); + printf("Buffer: Attempting to read %db.\n", iBufSize-iReadBufFill-iReadPos ); iReadBufFill += rNext.read( sReadBuf+iReadPos+iReadBufFill, iBufSize-iReadBufFill-iReadPos ); - //printf("Buffer: Read from stream, %db now in buffer.\n", iReadBufFill ); + printf("Buffer: Read from stream, %db now in buffer.\n", iReadBufFill ); } } @@ -152,3 +152,8 @@ void Bu::Buffer::flush() } } +bool Bu::Buffer::isEos() +{ + return iReadPos == (iReadBufFill-1) && rNext.isEos(); +} + diff --git a/src/buffer.h b/src/buffer.h index b931937..97d4127 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -30,6 +30,8 @@ namespace Bu virtual void flush(); + virtual bool isEos(); + private: void fillReadBuf(); diff --git a/src/cache.h b/src/cache.h index 06b798c..1753407 100644 --- a/src/cache.h +++ b/src/cache.h @@ -317,20 +317,23 @@ namespace Bu void erase( const keytype &cId ) { TRACE( cId ); - try { - if( hEnt.get( cId ).iRefs > 0 ) - { - printf("Shouldn't delete, references still exist!\n"); - return; + if( hEnt.has( cId ) ) + { + try { + if( hEnt.get( cId ).iRefs > 0 ) + { + printf("Shouldn't delete, references still exist!\n"); + return; + } } + catch( Bu::HashException &e ) { + get( cId ); + } + + pCalc->onUnload( hEnt.get( cId ).pData, cId ); + pStore->destroy( hEnt.get( cId ).pData, cId ); } - catch( Bu::HashException &e ) { - get( cId ); - } - - pCalc->onUnload( hEnt.get( cId ).pData, cId ); - - pStore->destroy( hEnt.get( cId ).pData, cId ); + hEnt.erase( cId ); } -- cgit v1.2.3