From cd5094ff920a80c0215294033e8701758620afde Mon Sep 17 00:00:00 2001 From: Sebastian Messmer Date: Mon, 5 Oct 2015 16:54:31 +0200 Subject: [PATCH] Added asserts that there are no open blocks when destructor runs --- ParallelAccessStore.h | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/ParallelAccessStore.h b/ParallelAccessStore.h index e60569e5..217ab1d1 100644 --- a/ParallelAccessStore.h +++ b/ParallelAccessStore.h @@ -22,20 +22,24 @@ template class ParallelAccessStore { public: explicit ParallelAccessStore(cpputils::unique_ref> baseStore); + ~ParallelAccessStore() { + ASSERT(_openResources.size() == 0, "Still resources open when trying to destruct"); + ASSERT(_resourcesToRemove.size() == 0, "Still resources to remove when trying to destruct"); + }; class ResourceRefBase { public: //TODO Better way to initialize - ResourceRefBase(): _cachingStore(nullptr), _key(Key::Null()) {} - void init(ParallelAccessStore *cachingStore, const Key &key) { - _cachingStore = cachingStore; + ResourceRefBase(): _parallelAccessStore(nullptr), _key(Key::Null()) {} + void init(ParallelAccessStore *parallelAccessStore, const Key &key) { + _parallelAccessStore = parallelAccessStore; _key = key; } virtual ~ResourceRefBase() { - _cachingStore->release(_key); + _parallelAccessStore->release(_key); } private: - ParallelAccessStore *_cachingStore; + ParallelAccessStore *_parallelAccessStore; //TODO We're storing Key twice (here and in the base resource). Rather use getKey() on the base resource if possible somehow. Key _key; };