diff options
Diffstat (limited to '')
-rw-r--r-- | src/cache.h | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/cache.h b/src/cache.h index ccc4966..036ceb4 100644 --- a/src/cache.h +++ b/src/cache.h | |||
@@ -100,6 +100,13 @@ namespace Bu | |||
100 | return kId; | 100 | return kId; |
101 | } | 101 | } |
102 | 102 | ||
103 | void unbind() | ||
104 | { | ||
105 | if( pCache && pData ) | ||
106 | pCache->decRef( kId ); | ||
107 | pData = NULL; | ||
108 | } | ||
109 | |||
103 | Ptr &operator=( const Ptr &rRhs ) | 110 | Ptr &operator=( const Ptr &rRhs ) |
104 | { | 111 | { |
105 | if( pCache && pData ) | 112 | if( pCache && pData ) |
@@ -186,6 +193,11 @@ namespace Bu | |||
186 | return Ptr( this, pData, k ); | 193 | return Ptr( this, pData, k ); |
187 | } | 194 | } |
188 | 195 | ||
196 | bool has( const keytype &cId ) | ||
197 | { | ||
198 | return hEnt.has( cId ) || pStore->has( cId ); | ||
199 | } | ||
200 | |||
189 | Ptr get( const keytype &cId ) | 201 | Ptr get( const keytype &cId ) |
190 | { | 202 | { |
191 | TRACE( cId ); | 203 | TRACE( cId ); |
@@ -260,6 +272,32 @@ namespace Bu | |||
260 | return pStore->getKeys(); | 272 | return pStore->getKeys(); |
261 | } | 273 | } |
262 | 274 | ||
275 | /** | ||
276 | * Make sure all currently loaded but not-in-use objects are synced to | ||
277 | * the store. | ||
278 | */ | ||
279 | void sync() | ||
280 | { | ||
281 | TRACE(); | ||
282 | int iSynced = 0; | ||
283 | for( typename CidHash::iterator i = hEnt.begin(); | ||
284 | i != hEnt.end(); i++ ) | ||
285 | { | ||
286 | if( i.getValue().iRefs == 0 ) | ||
287 | { | ||
288 | pStore->sync( | ||
289 | i.getValue().pData, | ||
290 | i.getKey() | ||
291 | ); | ||
292 | iSynced++; | ||
293 | } | ||
294 | } | ||
295 | if( iSynced > 0 ) | ||
296 | { | ||
297 | pStore->sync(); | ||
298 | } | ||
299 | } | ||
300 | |||
263 | private: | 301 | private: |
264 | void incRef( const keytype &cId ) | 302 | void incRef( const keytype &cId ) |
265 | { | 303 | { |