Template Class SharedHandle
Defined in File HandleWrapper.hpp
Inheritance Relationships
Derived Types
private nvcv::CoreResource< NVCVImageHandle, Image >
(Template Class CoreResource)private nvcv::CoreResource< NVCVTensorHandle, Tensor >
(Template Class CoreResource)private nvcv::CoreResource< NVCVImageBatchHandle, ImageBatch >
(Template Class CoreResource)private nvcv::CoreResource< NVCVTensorBatchHandle, TensorBatch >
(Template Class CoreResource)private nvcv::CoreResource< NVCVArrayHandle, Array >
(Template Class CoreResource)private nvcv::CoreResource< NVCVAllocatorHandle, Allocator >
(Template Class CoreResource)
Class Documentation
-
template<typename HandleType, typename HandleOps = detail::SharedHandleOps<HandleType>>
class SharedHandle A handle wrapper that behaves similarly shared_ptr.
Copying a SharedHandle increments the reference count. Destroying a SharedHandle decrements the reference count. Swap (and, to some, extent, move) are very simple operations on the handle value.
- Template Parameters:
HandleType – The type of the managed handle
HandleOps – The set of handle operations - can be customized e.g. to add extra operation tracking
Subclassed by nvcv::CoreResource< NVCVImageHandle, Image >, nvcv::CoreResource< NVCVTensorHandle, Tensor >, nvcv::CoreResource< NVCVImageBatchHandle, ImageBatch >, nvcv::CoreResource< NVCVTensorBatchHandle, TensorBatch >, nvcv::CoreResource< NVCVArrayHandle, Array >, nvcv::CoreResource< NVCVAllocatorHandle, Allocator >
Public Functions
-
inline ~SharedHandle()
-
SharedHandle() = default
-
inline explicit SharedHandle(HandleType &&handle) noexcept
Manages the handle in a new SharedHandle wrapper.
The reference count on the handle is not incremented.
- Parameters:
handle – The handle to be managed. The handle is passed by an r-value reference and is set to null to emphasize the transfer of ownership.
-
inline SharedHandle(SharedHandle &&other) noexcept
-
inline SharedHandle(const SharedHandle &other)
Creates a new shared reference to the handle managed by
other
.
-
inline SharedHandle &operator=(SharedHandle &&other)
Moves the handle owned by
other
into this object and releases the old handle.
-
inline SharedHandle &operator=(const SharedHandle &other)
Copies the handle managed by
other
tothis
and incremenets the reference count. Decrements the reference count on the previously owned handle.This function performs the following actions (in that order):
If the currently managed handle and
other
are equal, the function is a no-op.Increments the reference count on
other
(if not null)Replaces the managed handle by that from
other
.Decrements the reference count on the old handle (if not null).
-
inline void swap(SharedHandle &other) noexcept
Swaps the handles managed by
this
andother
.
-
inline int reset(HandleType &&handle = HandleOps::Null())
Replaces the currently managed handle with the one passed in the parameter.
This function performs the following actions (in that order):
Stores a copy of the “old” handle
Replaces the managed handle by that from
other
.Decrements the reference count on the old handle (if not null)
- Parameters:
handle – The handle to be managed. The handle is passed by an r-value reference and is set to null to emphasize the transfer of ownership.
- Returns:
The updated reference count of the old handle - if it’s zero, the object was destroyed or the handle was already null. If it’s >0, the object still had some live references.
-
inline HandleType release() noexcept
Relinquishes the ownership of the handle and returns the formerly managed handle.
The function returns the handle and stops managing it. The caller is resposnible for decrementing the reference count on the handle.
- Returns:
The (formerly) managed handle. The values must not be discarded.
-
inline constexpr const HandleType get() const noexcept
Returns the currently managed handle.
-
inline int refCount() const noexcept
-
inline constexpr bool empty() const noexcept
-
inline explicit constexpr operator bool() const noexcept
-
inline bool operator==(const SharedHandle &other) const
-
inline bool operator!=(const SharedHandle &other) const