aboutsummaryrefslogtreecommitdiff
path: root/src/cache.h
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2010-04-30 05:44:39 +0000
committerMike Buland <eichlan@xagasoft.com>2010-04-30 05:44:39 +0000
commitdaa25c26e99eb62a4ce499f8079b15734987ac0d (patch)
tree7b76a052f0bb1f5d72957838d12e0c49dfd7c093 /src/cache.h
parent1889b55dcbb3f5c5cccc3bcd986b13d0d108ed6c (diff)
downloadlibbu++-daa25c26e99eb62a4ce499f8079b15734987ac0d.tar.gz
libbu++-daa25c26e99eb62a4ce499f8079b15734987ac0d.tar.bz2
libbu++-daa25c26e99eb62a4ce499f8079b15734987ac0d.tar.xz
libbu++-daa25c26e99eb62a4ce499f8079b15734987ac0d.zip
Many minor fixes to the caching system, membuf, and others, but mainly some
important fixes for real-life use of the system.
Diffstat (limited to 'src/cache.h')
-rw-r--r--src/cache.h17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/cache.h b/src/cache.h
index 987443c..06b798c 100644
--- a/src/cache.h
+++ b/src/cache.h
@@ -205,6 +205,12 @@ namespace Bu
205 virtual ~Cache() 205 virtual ~Cache()
206 { 206 {
207 TRACE(); 207 TRACE();
208
209 // Better safe than sorry, better try a sync before anything
210 // else happens.
211 sync();
212
213 // Cycle through and unload all objects from the system.
208 for( typename CidHash::iterator i = hEnt.begin(); 214 for( typename CidHash::iterator i = hEnt.begin();
209 i != hEnt.end(); i++ ) 215 i != hEnt.end(); i++ )
210 { 216 {
@@ -214,10 +220,6 @@ namespace Bu
214 // object when the Cache is destroyed. 220 // object when the Cache is destroyed.
215 throw Bu::ExceptionBase("iRefs not zero."); 221 throw Bu::ExceptionBase("iRefs not zero.");
216 } 222 }
217 pCalc->onUnload(
218 i.getValue().pData,
219 i.getKey()
220 );
221 pStore->unload( 223 pStore->unload(
222 i.getValue().pData, 224 i.getValue().pData,
223 i.getKey() 225 i.getKey()
@@ -230,6 +232,8 @@ namespace Bu
230 Ptr insert( obtype *pData ) 232 Ptr insert( obtype *pData )
231 { 233 {
232 TRACE( pData ); 234 TRACE( pData );
235 if( pStore->has( __cacheGetKey<keytype, obtype>( pData ) ) )
236 throw Bu::ExceptionBase("Key already exists in cache.");
233 CacheEntry e = {pData, 0, 0}; 237 CacheEntry e = {pData, 0, 0};
234 keytype k = pStore->create( pData ); 238 keytype k = pStore->create( pData );
235 hEnt.insert( k, e ); 239 hEnt.insert( k, e );
@@ -336,6 +340,11 @@ namespace Bu
336 return pStore->getKeys(); 340 return pStore->getKeys();
337 } 341 }
338 342
343 KeyList getActiveKeys()
344 {
345 return hEnt.getKeys();
346 }
347
339 int getSize() 348 int getSize()
340 { 349 {
341 return pStore->getSize(); 350 return pStore->getSize();