diff options
author | Mike Buland <eichlan@xagasoft.com> | 2013-07-03 19:55:56 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2013-07-03 19:55:56 +0000 |
commit | 65cc54be0a14e627938731ff8deefea61c2c1cfa (patch) | |
tree | 8c52df22ffba1a21bb3b849660adf12ebd185208 /src/unstable/cachebase.h | |
parent | 7b1f2da0d83d4e01a8d8a32e02bea6b33c61e3f4 (diff) | |
download | libbu++-65cc54be0a14e627938731ff8deefea61c2c1cfa.tar.gz libbu++-65cc54be0a14e627938731ff8deefea61c2c1cfa.tar.bz2 libbu++-65cc54be0a14e627938731ff8deefea61c2c1cfa.tar.xz libbu++-65cc54be0a14e627938731ff8deefea61c2c1cfa.zip |
Modified the Bu::CacheBase API, what was erase is eraseNow, and erase is about
to be re-engineered to actually do a lazy erase like removing an iNode in a
posix filesystem. While the file remains open it exists, but the references
visible to the user on disk are gone.
Diffstat (limited to 'src/unstable/cachebase.h')
-rw-r--r-- | src/unstable/cachebase.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/unstable/cachebase.h b/src/unstable/cachebase.h index 270c2df..6cc3e77 100644 --- a/src/unstable/cachebase.h +++ b/src/unstable/cachebase.h | |||
@@ -393,8 +393,27 @@ namespace Bu | |||
393 | return CachePtr<keytype, castto, obtype>( this, ptr.kId ); | 393 | return CachePtr<keytype, castto, obtype>( this, ptr.kId ); |
394 | } | 394 | } |
395 | 395 | ||
396 | /** | ||
397 | * Removes an item from the cache. | ||
398 | * This routine calls eraseNow for now. Later the intention is that | ||
399 | * this function will always succeed. It will remove the object from | ||
400 | * the backing store and the active tables. It will not be able to | ||
401 | * be requested again, and all changes will be ignored. When the | ||
402 | * object's last references are released the memory will be freed | ||
403 | * automatically. | ||
404 | */ | ||
396 | void erase( const keytype &key ) | 405 | void erase( const keytype &key ) |
397 | { | 406 | { |
407 | eraseNow( key ); | ||
408 | } | ||
409 | |||
410 | /** | ||
411 | * Removes an item from the cache and frees memory immediately. | ||
412 | * The object in question cannot have any active references in order | ||
413 | * for this to succeed, otherwise it will throw an exception. | ||
414 | */ | ||
415 | void eraseNow( const keytype &key ) | ||
416 | { | ||
398 | Bu::ReadWriteMutex::WriteLocker wl( mCacheEntry ); | 417 | Bu::ReadWriteMutex::WriteLocker wl( mCacheEntry ); |
399 | if( hCacheEntry.has( key ) ) | 418 | if( hCacheEntry.has( key ) ) |
400 | { | 419 | { |
@@ -456,6 +475,8 @@ namespace Bu | |||
456 | Entry *pEnt = new Entry( pObject ); | 475 | Entry *pEnt = new Entry( pObject ); |
457 | mCacheEntry.lockWrite(); | 476 | mCacheEntry.lockWrite(); |
458 | hCacheEntry.insert( pObject->getKey(), pEnt ); | 477 | hCacheEntry.insert( pObject->getKey(), pEnt ); |
478 | if( pObject->hasChanged() ) | ||
479 | hChanged.insert( pObject->getKey(), true ); | ||
459 | mCacheEntry.unlockWrite(); | 480 | mCacheEntry.unlockWrite(); |
460 | _create( pObject ); | 481 | _create( pObject ); |
461 | pObject->setCache( this, pEnt ); | 482 | pObject->setCache( this, pEnt ); |