32 #ifndef VSMC_GCD_DISPATCH_OBJECT_HPP
33 #define VSMC_GCD_DISPATCH_OBJECT_HPP
36 #include <dispatch/dispatch.h>
44 template <
typename DispatchType>
57 object_(object) {
if (!retained) retain();}
60 object_(other.object_) {retain();}
65 if (
this != &other && object_ != other.object_) {
67 object_ = other.object_;
74 #if VSMC_HAS_CXX11_RVALUE_REFERENCES
83 if (
this != &other && object_ != other.object_)
84 swap(object_, other.object_);
93 DispatchType
object ()
const {
return object_;}
106 {return ::dispatch_get_context(object_);}
109 {::dispatch_set_context(object_, context);}
112 {::dispatch_set_finalizer_f(object_, finalizer);}
116 DispatchType object_;
121 ::dispatch_retain(object_);
127 ::dispatch_release(object_);
133 #endif // VSMC_GCD_DISPATCH_OBJECT_HPP
Base class of Dispatch objects.
DispatchObject(DispatchObject< DispatchType > &&other)
void * get_context() const
DispatchObject(const DispatchObject< DispatchType > &other)
void object(DispatchType obj)
Set the underlying Dispatch object and retain it.
void set_context(void *context) const
remove_reference< T >::type && move(T &&t) noexcept
#define VSMC_NULLPTR
nullptr
void swap(Array< T, N > &ary1, Array< T, N > &ary2)
Array ADL of swap.
DispatchObject(const DispatchType &object, bool retained)
Create a DispatchObject from its C-type object.
void set_finalizer_f(::dispatch_function_t finalizer) const
DispatchObject< DispatchType > & operator=(const DispatchObject< DispatchType > &other)
DispatchType object() const
Return the underlying Dispatch object.