22#ifndef NDN_CXX_DETAIL_CANCEL_HANDLE_HPP
23#define NDN_CXX_DETAIL_CANCEL_HANDLE_HPP
54 mutable std::function<void()> m_cancel;
63template<typename HandleT>
66 static_assert(std::is_convertible_v<HandleT*, CancelHandle*>,
67 "HandleT must publicly derive from CancelHandle");
75 : m_hdl(
std::move(hdl))
86 : m_hdl(other.release())
101 m_hdl = other.release();
126 return std::exchange(m_hdl, HandleT{});
130 operator bool() const noexcept
Handle to cancel an operation.
void cancel() const
Cancel the operation.
Cancels an operation automatically upon destruction.
ScopedCancelHandle & operator=(ScopedCancelHandle &&other)
Move assignment operator.
ScopedCancelHandle() noexcept
~ScopedCancelHandle()
Cancel the operation.
ScopedCancelHandle(const ScopedCancelHandle &)=delete
Copy construction is disallowed.
ScopedCancelHandle & operator=(const ScopedCancelHandle &)=delete
Copy assignment is disallowed.
ScopedCancelHandle(ScopedCancelHandle &&other) noexcept
Move constructor.
HandleT release() noexcept
Release the operation so that it won't be cancelled when this ScopedCancelHandle is destructed.
void cancel()
Cancel the operation.
Contains implementation details that are not part of the ndn-cxx public API.