Cholla 3.0.1-dev
Cholla - Massively parallel hydro on GPUs
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
SharedHandle< HandleT > Class Template Reference

Wraps a handles while providing shared object semantics. More...

#include <shared.h>

Public Types

typedef HandleT wrapped_ref_type
 

Public Member Functions

__host__ __device__ SharedHandle ()
 Default Constructor (constructs an empty instance)
 
template<typename Deleter >
__host__ SharedHandle (HandleT handle, Deleter d)
 Primary constructor.
 
__host__ __device__ ~SharedHandle () noexcept
 Destructor.
 
__host__ __device__ SharedHandle (const SharedHandle &other) noexcept
 
__host__ __device__ SharedHandle (SharedHandle &&other) noexcept
 
__host__ __device__ SharedHandleoperator= (const SharedHandle &other) noexcept
 
__host__ __device__ SharedHandleoperator= (SharedHandle &&other) noexcept
 
__host__ __device__ void swap (SharedHandle &o) noexcept
 swap the contents of this and other
 
__host__ __device__ void reset () noexcept
 Release ownership of the owned resource (if any)
 
__host__ __device__ __forceinline__ HandleT get () const noexcept
 Return the stored handle.
 
__host__ __device__ operator bool () const noexcept
 returns false if this is empty
 

Detailed Description

template<typename HandleT>
class SharedHandle< HandleT >

Wraps a handles while providing shared object semantics.

At a high level this analogous to shared_ptr, but for handles.

This type primarily exists in order to wrap the cudaTextureObject_t handle.

Constructor & Destructor Documentation

◆ SharedHandle() [1/2]

template<typename HandleT >
__host__ __device__ SharedHandle< HandleT >::SharedHandle ( )
inline

Default Constructor (constructs an empty instance)

Note
A compelling case could be made for not having a default constructor, at all. For now, we define for the sake of symmetry with SharedPtr, and it makes composition of classes that use SharedHandle easier for less experienced C++ developers

◆ SharedHandle() [2/2]

template<typename HandleT >
template<typename Deleter >
__host__ SharedHandle< HandleT >::SharedHandle ( HandleT  handle,
Deleter  d 
)
inline

Primary constructor.

d is a callback function-like object that is used deallocate handle when all SharedHandle instances that wrap handle release ownership. The callback will be invoked as d(handle)

Parameters
handlethe handle to be managed by the constructed instance
dA deleter instance used to destroy the handle
Warning
Passing a handle that is already owned by another SharedHandle leads to undefined behavior

Member Function Documentation

◆ reset()

template<typename HandleT >
__host__ __device__ void SharedHandle< HandleT >::reset ( )
noexcept

Release ownership of the owned resource (if any)

This is equivalent to SharedHandle().swap(*this);


The documentation for this class was generated from the following file: