diff options
| author | Mike Buland <eichlan@xagasoft.com> | 2010-04-30 05:44:39 +0000 |
|---|---|---|
| committer | Mike Buland <eichlan@xagasoft.com> | 2010-04-30 05:44:39 +0000 |
| commit | daa25c26e99eb62a4ce499f8079b15734987ac0d (patch) | |
| tree | 7b76a052f0bb1f5d72957838d12e0c49dfd7c093 | |
| parent | 1889b55dcbb3f5c5cccc3bcd986b13d0d108ed6c (diff) | |
| download | libbu++-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 '')
| -rw-r--r-- | src/cache.h | 17 | ||||
| -rw-r--r-- | src/cachestoremyriad.h | 5 | ||||
| -rw-r--r-- | src/cachestorenids.h | 5 | ||||
| -rw-r--r-- | src/membuf.cpp | 6 | ||||
| -rw-r--r-- | src/membuf.h | 1 |
5 files changed, 20 insertions, 14 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(); |
diff --git a/src/cachestoremyriad.h b/src/cachestoremyriad.h index e5a10eb..3ae3ec8 100644 --- a/src/cachestoremyriad.h +++ b/src/cachestoremyriad.h | |||
| @@ -88,9 +88,6 @@ namespace Bu | |||
| 88 | 88 | ||
| 89 | virtual void unload( obtype *pObj, const keytype &key ) | 89 | virtual void unload( obtype *pObj, const keytype &key ) |
| 90 | { | 90 | { |
| 91 | int iStream = hId.get( key ); | ||
| 92 | MyriadStream ns = mStore.openStream( iStream ); | ||
| 93 | __cacheStoreMyriadStore<keytype, obtype>( ns, *pObj, key ); | ||
| 94 | delete pObj; | 91 | delete pObj; |
| 95 | } | 92 | } |
| 96 | 93 | ||
| @@ -109,8 +106,6 @@ namespace Bu | |||
| 109 | MyriadStream ns = mStore.openStream( 1 ); | 106 | MyriadStream ns = mStore.openStream( 1 ); |
| 110 | Bu::Archive ar( ns, Bu::Archive::save ); | 107 | Bu::Archive ar( ns, Bu::Archive::save ); |
| 111 | ar << hId; | 108 | ar << hId; |
| 112 | |||
| 113 | mStore.sync(); | ||
| 114 | } | 109 | } |
| 115 | 110 | ||
| 116 | virtual void sync( obtype *pSrc, const keytype &key ) | 111 | virtual void sync( obtype *pSrc, const keytype &key ) |
diff --git a/src/cachestorenids.h b/src/cachestorenids.h index c9e8fd1..54129b0 100644 --- a/src/cachestorenids.h +++ b/src/cachestorenids.h | |||
| @@ -89,9 +89,6 @@ namespace Bu | |||
| 89 | 89 | ||
| 90 | virtual void unload( obtype *pObj, const keytype &key ) | 90 | virtual void unload( obtype *pObj, const keytype &key ) |
| 91 | { | 91 | { |
| 92 | int iStream = hId.get( key ); | ||
| 93 | NidsStream ns = nStore.openStream( iStream ); | ||
| 94 | __cacheStoreNidsStore<keytype, obtype>( ns, *pObj, key ); | ||
| 95 | delete pObj; | 92 | delete pObj; |
| 96 | } | 93 | } |
| 97 | 94 | ||
| @@ -110,8 +107,6 @@ namespace Bu | |||
| 110 | NidsStream ns = nStore.openStream( 0 ); | 107 | NidsStream ns = nStore.openStream( 0 ); |
| 111 | Bu::Archive ar( ns, Bu::Archive::save ); | 108 | Bu::Archive ar( ns, Bu::Archive::save ); |
| 112 | ar << hId; | 109 | ar << hId; |
| 113 | |||
| 114 | nStore.sync(); | ||
| 115 | } | 110 | } |
| 116 | 111 | ||
| 117 | virtual void sync( obtype *pSrc, const keytype &key ) | 112 | virtual void sync( obtype *pSrc, const keytype &key ) |
diff --git a/src/membuf.cpp b/src/membuf.cpp index fc2ebfa..0c1c441 100644 --- a/src/membuf.cpp +++ b/src/membuf.cpp | |||
| @@ -145,3 +145,9 @@ Bu::FString &Bu::MemBuf::getString() | |||
| 145 | return sBuf; | 145 | return sBuf; |
| 146 | } | 146 | } |
| 147 | 147 | ||
| 148 | void Bu::MemBuf::setString( const Bu::FString &sNewData ) | ||
| 149 | { | ||
| 150 | sBuf = sNewData; | ||
| 151 | nPos = 0; | ||
| 152 | } | ||
| 153 | |||
diff --git a/src/membuf.h b/src/membuf.h index 3de8552..c6c8079 100644 --- a/src/membuf.h +++ b/src/membuf.h | |||
| @@ -47,6 +47,7 @@ namespace Bu | |||
| 47 | virtual void setBlocking( bool bBlocking=true ); | 47 | virtual void setBlocking( bool bBlocking=true ); |
| 48 | 48 | ||
| 49 | Bu::FString &getString(); | 49 | Bu::FString &getString(); |
| 50 | void setString( const Bu::FString &sNewData ); | ||
| 50 | 51 | ||
| 51 | private: | 52 | private: |
| 52 | Bu::FString sBuf; | 53 | Bu::FString sBuf; |
