22 #ifndef NDN_CXX_DETAIL_CANCEL_HANDLE_HPP
23 #define NDN_CXX_DETAIL_CANCEL_HANDLE_HPP
39 : m_cancel(std::move(
cancel))
49 mutable std::function<void()> m_cancel;
57 template<typename HandleT>
60 static_assert(std::is_convertible<HandleT*, CancelHandle*>::value,
61 "HandleT must publicly derive from CancelHandle");
69 : m_hdl(std::move(hdl))
80 : m_hdl(other.release())
95 m_hdl = other.release();
120 return std::exchange(m_hdl, HandleT{});
124 operator bool() const noexcept
Handle to cancel an operation.
void cancel() const
Cancel the operation.
Cancels an operation automatically upon destruction.
ScopedCancelHandle() noexcept
~ScopedCancelHandle()
Cancel the operation.
ScopedCancelHandle(const ScopedCancelHandle &)=delete
Copy construction 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.
ScopedCancelHandle & operator=(ScopedCancelHandle &&other)
Move assignment operator.
ScopedCancelHandle & operator=(const ScopedCancelHandle &)=delete
Copy assignment is disallowed.
void cancel()
Cancel the operation.
Common includes and macros used throughout the library.