Browse Source

unset the weak-wait-flag on deallocation for CacheData which is where completion guarantee is required, also extend some comments in CacheData

master
Constantin Fürst 11 months ago
parent
commit
ef8286da17
  1. 23
      offloading-cacher/cache.hpp

23
offloading-cacher/cache.hpp

@ -138,13 +138,26 @@ namespace dsacache {
// waits on completion of caching operations // waits on completion of caching operations
// for this task and is safe to be called in // for this task and is safe to be called in
// any state of the object
// any state of the object, if the flag
// FLAG_WAIT_WEAK is set for this instance
// (can also be inherited from the creating
// Cache-Instance or on copy from another
// CacheData-Instance), WaitOnCompletion
// provides no validity guarantees to the
// cache pointer (GetDataLocation() may
// return nullptr even after return
// of the wait function). On error this
// function will set the cache pointer
// to the source to provide validity
// guarantees after returning.
void WaitOnCompletion(); void WaitOnCompletion();
// returns the cache data location for this // returns the cache data location for this
// instance which is valid as long as the // instance which is valid as long as the
// instance is alive - !!! this may also
// yield a nullptr !!!
// instance is alive
// !!! this may also return a nullptr !!!
// see WaitOnCompletion() for how to achieve
// validity guarantees if required
uint8_t* GetDataLocation() const { return cache_->load(); } uint8_t* GetDataLocation() const { return cache_->load(); }
void SetFlags(const uint64_t flags) { flags_ = flags; } void SetFlags(const uint64_t flags) { flags_ = flags; }
@ -673,7 +686,11 @@ inline dsacache::CacheData::~CacheData() {
if (v == 0) { if (v == 0) {
// on deletion we must ensure that all offloaded // on deletion we must ensure that all offloaded
// operations have completed successfully // operations have completed successfully
// for this we must unset the possibly active
// flag for weak waiting as we wish completion
// guarantees afterwards
flags_ = UnsetFlag(flags_, FLAG_WAIT_WEAK);
WaitOnCompletion(); WaitOnCompletion();
// only then can we deallocate the memory // only then can we deallocate the memory

Loading…
Cancel
Save