Added asserts that there are no open blocks when destructor runs
This commit is contained in:
parent
e873418477
commit
cd5094ff92
@ -22,20 +22,24 @@ template<class Resource, class ResourceRef, class Key>
|
|||||||
class ParallelAccessStore {
|
class ParallelAccessStore {
|
||||||
public:
|
public:
|
||||||
explicit ParallelAccessStore(cpputils::unique_ref<ParallelAccessBaseStore<Resource, Key>> baseStore);
|
explicit ParallelAccessStore(cpputils::unique_ref<ParallelAccessBaseStore<Resource, Key>> 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 {
|
class ResourceRefBase {
|
||||||
public:
|
public:
|
||||||
//TODO Better way to initialize
|
//TODO Better way to initialize
|
||||||
ResourceRefBase(): _cachingStore(nullptr), _key(Key::Null()) {}
|
ResourceRefBase(): _parallelAccessStore(nullptr), _key(Key::Null()) {}
|
||||||
void init(ParallelAccessStore *cachingStore, const Key &key) {
|
void init(ParallelAccessStore *parallelAccessStore, const Key &key) {
|
||||||
_cachingStore = cachingStore;
|
_parallelAccessStore = parallelAccessStore;
|
||||||
_key = key;
|
_key = key;
|
||||||
}
|
}
|
||||||
virtual ~ResourceRefBase() {
|
virtual ~ResourceRefBase() {
|
||||||
_cachingStore->release(_key);
|
_parallelAccessStore->release(_key);
|
||||||
}
|
}
|
||||||
private:
|
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.
|
//TODO We're storing Key twice (here and in the base resource). Rather use getKey() on the base resource if possible somehow.
|
||||||
Key _key;
|
Key _key;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user