Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef XDISPATCH_BLOCKS_H_
00029 #define XDISPATCH_BLOCKS_H_
00030
00031 #ifndef __XDISPATCH_INDIRECT__
00032 #error "Please #include <xdispatch/dispatch.h> instead of this file directly."
00033 #endif
00034
00091
00092 #ifdef __BLOCKS__
00093 # include <Block.h>
00094 # include <stddef.h>
00095 # define XDISPATCH_BLOCK ^
00096 # ifndef XDISPATCH_NO_KEYWORDS
00097 # define $ ^
00098 # endif
00099 # define XDISPATCH_BLOCK_PERSIST(A) Block_copy(A)
00100 # define XDISPATCH_BLOCK_COPY(A) Block_copy(A)
00101 # define XDISPATCH_BLOCK_DELETE(A) Block_release(A)
00102 # define XDISPATCH_BLOCK_EXEC(A) (A)
00103
00104 typedef void (^dispatch_iteration_block_t)(size_t);
00105 typedef dispatch_block_t dispatch_block_store;
00106 typedef dispatch_iteration_block_t dispatch_iteration_block_store;
00107 # define XDISPATCH_HAS_BLOCKS
00108 # if defined(__cplusplus) && !defined(__clang__)
00109 # warning "Sadly blocks are currently broken in C++ on this platform, we recommend using gcc 4.5.1 or clang 2.0 instead"
00110 # endif
00111
00112
00113 #elif _MSC_VER >= 1600
00114
00115 # include <functional>
00116 # define XDISPATCH_BLOCK [=]
00117 # ifndef XDISPATCH_NO_KEYWORDS
00118 # define $ [=]
00119 # endif
00120 # define XDISPATCH_BLOCK_PERSIST(A) (A)
00121 # define XDISPATCH_BLOCK_COPY(A) (A)
00122 # define XDISPATCH_BLOCK_DELETE(A) {}
00123 # define XDISPATCH_BLOCK_EXEC(A) (A)
00124 typedef const std::tr1::function< void (void) >& dispatch_block_t;
00125 typedef const std::tr1::function< void (size_t) >& dispatch_iteration_block_t;
00126 typedef std::tr1::function< void (void) > dispatch_block_store;
00127 typedef std::tr1::function< void (size_t) > dispatch_iteration_block_store;
00128 # define XDISPATCH_HAS_BLOCKS
00129
00130
00131 #elif defined __GXX_EXPERIMENTAL_CXX0X__
00132
00133 # include <tr1/functional>
00134 # define XDISPATCH_BLOCK [=]
00135 # ifndef XDISPATCH_NO_KEYWORDS
00136 # define $ [=]
00137 # endif
00138 # define XDISPATCH_BLOCK_PERSIST(A) (A)
00139 # define XDISPATCH_BLOCK_COPY(A) (A)
00140 # define XDISPATCH_BLOCK_DELETE(A) {}
00141 # define XDISPATCH_BLOCK_EXEC(A) (A)
00142 typedef const std::tr1::function< void (void) >& dispatch_block_t;
00143 typedef const std::tr1::function< void (size_t) >& dispatch_iteration_block_t;
00144 typedef std::tr1::function< void (void) > dispatch_block_store;
00145 typedef std::tr1::function< void (size_t) > dispatch_iteration_block_store;
00146 # define XDISPATCH_HAS_BLOCKS
00147
00148 #else
00149
00150 # define XDISPATCH_BLOCK "No Block support!"
00151
00152 #endif
00153
00154 #if defined(XDISPATCH_HAS_BLOCKS) && !defined(__BLOCKS__)
00155
00156 #ifndef XDISPATCH_EXPORT
00157 # ifdef _WIN32
00158 # ifdef XDISPATCH_MAKEDLL
00159 # define XDISPATCH_EXPORT __declspec(dllexport)
00160 # else
00161 # define XDISPATCH_EXPORT __declspec(dllimport)
00162 # endif
00163 # else
00164 # define XDISPATCH_EXPORT __attribute__((visibility("default")))
00165 # endif
00166 #endif
00167
00168 XDISPATCH_EXPORT void dispatch_async(dispatch_queue_t queue, dispatch_block_t function);
00169
00170 XDISPATCH_EXPORT void dispatch_after(dispatch_time_t when, dispatch_queue_t queue, dispatch_block_t function);
00171
00172 XDISPATCH_EXPORT void dispatch_sync(dispatch_queue_t queue, dispatch_block_t function);
00173
00174 XDISPATCH_EXPORT void dispatch_apply(size_t iterations, dispatch_queue_t queue, dispatch_iteration_block_t function);
00175
00176 XDISPATCH_EXPORT void dispatch_group_async(dispatch_group_t group, dispatch_queue_t queue, dispatch_block_t function);
00177
00178 XDISPATCH_EXPORT void dispatch_group_notify(dispatch_group_t group, dispatch_queue_t queue, dispatch_block_t block);
00179
00180 XDISPATCH_EXPORT void dispatch_source_set_event_handler(dispatch_source_t source, dispatch_block_t handler);
00181
00182 XDISPATCH_EXPORT void dispatch_source_set_cancel_handler(dispatch_source_t source, dispatch_block_t cancel_handler);
00183
00184 XDISPATCH_EXPORT void dispatch_once(dispatch_once_t *predicate, dispatch_block_t block);
00185
00186 #endif
00187
00188 #endif