diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/tests/random.cpp | 7 | ||||
-rw-r--r-- | src/unstable/cachebase.h | 21 |
2 files changed, 28 insertions, 0 deletions
diff --git a/src/tests/random.cpp b/src/tests/random.cpp index d7b94ce..07a2a06 100644 --- a/src/tests/random.cpp +++ b/src/tests/random.cpp | |||
@@ -41,6 +41,13 @@ void coverage() | |||
41 | 41 | ||
42 | int main() | 42 | int main() |
43 | { | 43 | { |
44 | RandomCmwc c( 123456 ); | ||
45 | for( int j = 0; j < 10; j++ ) | ||
46 | { | ||
47 | println("%1").arg( c.rand() ); | ||
48 | } | ||
49 | return 0; | ||
50 | |||
44 | coverage<RandomBasic>(); | 51 | coverage<RandomBasic>(); |
45 | coverage<RandomCmwc>(); | 52 | coverage<RandomCmwc>(); |
46 | coverage<RandomSystem>(); | 53 | coverage<RandomSystem>(); |
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 ); |