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
00094 # include <Block.h>
00095 # include <stddef.h>
00096 # define XDISPATCH_BLOCK ^
00097 # ifndef XDISPATCH_NO_KEYWORDS
00098 # define $ ^
00099 # endif
00100 # define XDISPATCH_BLOCK_COPY(A) Block_copy(A)
00101 # define XDISPATCH_BLOCK_RELEASE(A) Block_release(A)
00102
00103 typedef void (^dispatch_iteration_block_t)(size_t);
00104 # define XDISPATCH_HAS_BLOCKS
00105 # if defined(__cplusplus) && !defined(__clang__)
00106 # warning "Sadly blocks are currently broken in C++ on this platform, we recommend using gcc 4.5.1 or clang 2.0 instead"
00107 # endif
00108
00109
00110 #elif _MSC_VER >= 1600
00111
00112 # include <functional>
00113 # define XDISPATCH_BLOCK [=]
00114 # ifndef XDISPATCH_NO_KEYWORDS
00115 # define $ [=]
00116 # endif
00117 # define XDISPATCH_BLOCK_COPY(A) A
00118 # define Block_copy(A) XDISPATCH_BLOCK_COPY(A)
00119 # define XDISPATCH_BLOCK_RELEASE(A) {}
00120 # define Block_release(A) XDISPATCH_BLOCK_RELEASE(A)
00121 typedef std::tr1::function< void (void) > dispatch_block_t;
00122 typedef std::tr1::function< void (size_t) > dispatch_iteration_block_t;
00123 # define XDISPATCH_HAS_BLOCKS
00124
00125
00126 #elif defined __GXX_EXPERIMENTAL_CXX0X__
00127
00128 # include <tr1/functional>
00129 # define XDISPATCH_BLOCK [=]
00130 # ifndef XDISPATCH_NO_KEYWORDS
00131 # define $ [=]
00132 # endif
00133 # define XDISPATCH_BLOCK_COPY(A) A
00134 # define Block_copy(A) XDISPATCH_BLOCK_COPY(A)
00135 # define XDISPATCH_BLOCK_RELEASE(A) {}
00136 # define Block_release(A) XDISPATCH_BLOCK_RELEASE(A)
00137 typedef std::tr1::function< void (void) > dispatch_block_t;
00138 typedef std::tr1::function< void (size_t) > dispatch_iteration_block_t;
00139 # define XDISPATCH_HAS_BLOCKS
00140
00141 #else
00142
00143 # define XDISPATCH_BLOCK "No Block support!"
00144
00145 #endif
00146
00147 #if defined(XDISPATCH_HAS_BLOCKS) && !defined(__BLOCKS__)
00148
00149 #ifndef XDISPATCH_EXPORT
00150 # ifdef _WIN32
00151 # ifdef XDISPATCH_MAKEDLL
00152 # define XDISPATCH_EXPORT __declspec(dllexport)
00153 # else
00154 # define XDISPATCH_EXPORT __declspec(dllimport)
00155 # endif
00156 # else
00157 # define XDISPATCH_EXPORT __attribute__((visibility("default")))
00158 # endif
00159 #endif
00160
00161 XDISPATCH_EXPORT void dispatch_async(dispatch_queue_t queue, dispatch_block_t function);
00162
00163 XDISPATCH_EXPORT void dispatch_after(dispatch_time_t when, dispatch_queue_t queue, dispatch_block_t function);
00164
00165 XDISPATCH_EXPORT void dispatch_sync(dispatch_queue_t queue, dispatch_block_t function);
00166
00167 XDISPATCH_EXPORT void dispatch_apply(size_t iterations, dispatch_queue_t queue, dispatch_iteration_block_t function);
00168
00169 XDISPATCH_EXPORT void dispatch_group_async(dispatch_group_t group, dispatch_queue_t queue, dispatch_block_t function);
00170
00171 XDISPATCH_EXPORT void dispatch_group_notify(dispatch_group_t group, dispatch_queue_t queue, dispatch_block_t block);
00172
00173 XDISPATCH_EXPORT void dispatch_source_set_event_handler(dispatch_source_t source, dispatch_block_t handler);
00174
00175 XDISPATCH_EXPORT void dispatch_source_set_cancel_handler(dispatch_source_t source, dispatch_block_t cancel_handler);
00176
00177 XDISPATCH_EXPORT void dispatch_once(dispatch_once_t *predicate, dispatch_block_t block);
00178
00179 #endif
00180
00181 #endif