55 virtual ~ResourceLock() =
default;
58 template <
typename T>
class ResourceLockImpl :
public ResourceLock {
59 std::shared_ptr<T> m_resource;
62 explicit ResourceLockImpl(std::shared_ptr<T>
resource)
64 ~ResourceLockImpl()
override { m_resource.reset(); }
67 template <
typename T>
using LifoList = std::stack<T, std::list<T>>;
69 LifoList<std::unique_ptr<ResourceLock>> m_resources;
75 while (
not m_resources.empty()) {
100 bool is_valid()
const {
return m_status.use_count() != 0; }
103 std::weak_ptr<void> m_status;
Manager to control the lifetime of shared resources.
void acquire_lock(std::shared_ptr< T > resource)
ResourceManager()=default
cudaStream_t stream[1]
CUDA streams for parallel computing on CPU and GPU.
Observer to monitor the lifetime of a shared resource.
ResourceObserver(std::shared_ptr< T > const &status)