32 #ifndef VSMC_GCD_DISPATCH_QUEUE_HPP
33 #define VSMC_GCD_DISPATCH_QUEUE_HPP
37 #include <dispatch/dispatch.h>
57 void resume ()
const {::dispatch_resume(this->
object());}
59 void suspend ()
const {::dispatch_suspend(this->
object());}
62 {return ::dispatch_queue_get_label(this->
object());}
66 {return ::dispatch_queue_get_specific(this->
object(), key);}
69 ::dispatch_function_t destructor)
const
70 {::dispatch_queue_set_specific(this->
object(), key, context, destructor);}
71 #endif // VSMC_HAS_GCD_LION
73 template <
typename DispatchType>
75 {::dispatch_set_target_queue(
object.
object(), this->
object());}
78 {::dispatch_set_target_queue(
object, this->
object());}
80 void after_f (::dispatch_time_t when,
void *context,
81 ::dispatch_function_t f)
const
82 {::dispatch_after_f(when, this->
object(), context, f);}
84 void apply_f (std::size_t iterations,
void *context,
85 void (*work) (
void *, std::size_t))
const
86 {::dispatch_apply_f(iterations, this->
object(), context, work);}
88 void async_f (
void *context, ::dispatch_function_t work)
const
89 {::dispatch_async_f(this->
object(), context, work);}
91 void sync_f (
void *context, ::dispatch_function_t work)
const
92 {::dispatch_sync_f(this->
object(), context, work);}
96 {::dispatch_barrier_async_f(this->
object(), context, work);}
99 {::dispatch_barrier_sync_f(this->
object(), context, work);}
100 #endif // VSMC_HAS_GCD_LION
103 void after (::dispatch_time_t when, ::dispatch_block_t block)
const
104 {::dispatch_after(when, this->
object(), block);}
106 void apply (std::size_t iterations,
void (^block) (std::size_t))
const
107 {::dispatch_apply(iterations, this->
object(), block);}
109 void async (::dispatch_block_t block)
const
110 {::dispatch_async(this->
object(), block);}
112 void sync (::dispatch_block_t block)
const
113 {::dispatch_sync(this->
object(), block);}
115 #if VSMC_HAS_GCD_LION
117 {::dispatch_barrier_async(this->
object(), block);}
120 {::dispatch_barrier_sync(this->
object(), block);}
121 #endif // VSMC_HAS_GCD_LION
147 #if VSMC_HAS_GCD_LION
149 DISPATCH_QUEUE_PRIORITY_DEFAULT,
unsigned long flags = 0) :
152 #else // VSMC_HAS_GCD_LION
156 #endif // VSMC_HAS_GCD_LION
173 #endif // VSMC_GCD_DISPATCH_QUEUE_HPP
Base class of DispatchQueue.
void * get_specific(const void *key) const
Base class of Dispatch objects.
void set_target_queue(const DispatchObject< DispatchType > &object) const
void after_f(::dispatch_time_t when, void *context,::dispatch_function_t f) const
void async(::dispatch_block_t block) const
The queue created by dispatch_queue_create
void barrier_async(::dispatch_block_t block) const
DispatchQueueBase(::dispatch_queue_t queue, bool retained)
void barrier_sync_f(void *context,::dispatch_function_t work) const
void after(::dispatch_time_t when,::dispatch_block_t block) const
void sync(::dispatch_block_t block) const
void apply_f(std::size_t iterations, void *context, void(*work)(void *, std::size_t)) const
void set_target_queue(::dispatch_object_t object) const
const char * get_label() const
The queue obtained by dispatch_get_gloal_queue
#define VSMC_NULLPTR
nullptr
void sync_f(void *context,::dispatch_function_t work) const
void barrier_sync(::dispatch_block_t block) const
The queue obtained by dispatch_get_main_queue
void barrier_async_f(void *context,::dispatch_function_t work) const
DispatchQueue(::dispatch_queue_priority_t priority=DISPATCH_QUEUE_PRIORITY_DEFAULT, unsigned long flags=0)
void apply(std::size_t iterations, void(^block)(std::size_t)) const
DispatchQueue(const char *label=nullptr,::dispatch_queue_attr_t attr=nullptr)
DispatchQueueType
Types of DispatchQueue.
void async_f(void *context,::dispatch_function_t work) const
void set_specific(const void *key, void *context,::dispatch_function_t destructor) const