#pragma once #include "recycler.hpp" template class DeferredRecycler : Recycler { public: using Recycler::acquire; void recycle(T* item) { auto guard = this->acquire_unique(); dirty.push_back(item); } void clean() { auto guard = this->acquire_unique(); for(auto item : dirty) this->recycle_or_delete(item); dirty.clear(); } private: std::queue dirty; };