XDispatch 0.7.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
lambda_dispatch.h
Go to the documentation of this file.
00001 /*
00002 * Copyright (c) 2008-2009 Apple Inc. All rights reserved.
00003 * Copyright (c) 2011-2012 MLBA-Team. All rights reserved.
00004 *
00005 * @MLBA_OPEN_LICENSE_HEADER_START@
00006 *
00007 * Licensed under the Apache License, Version 2.0 (the "License");
00008 * you may not use this file except in compliance with the License.
00009 * You may obtain a copy of the License at
00010 * 
00011 *     http://www.apache.org/licenses/LICENSE-2.0
00012 * 
00013 * Unless required by applicable law or agreed to in writing, software
00014 * distributed under the License is distributed on an "AS IS" BASIS,
00015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00016 * See the License for the specific language governing permissions and
00017 * limitations under the License.
00018 *
00019 * @MLBA_OPEN_LICENSE_HEADER_END@
00020 */
00021 
00022 
00023 /* When building on 10.6 with gcc 4.5.1 we can bypass
00024     Apple's lambda functions implementation in C++ as we have lambdas.
00025        This prevents a lot of errors from occuring
00026        */
00027 
00028 #ifndef XDISPATCH_LAMBDA_DISPATCH_H_
00029 #define XDISPATCH_LAMBDA_DISPATCH_H_
00030 
00036 #ifndef __XDISPATCH_INDIRECT__
00037 #error "Please #include <xdispatch/dispatch.h> instead of this file directly."
00038 #endif
00039 
00041 
00042 #ifdef __cplusplus
00043 
00044 // needed for dispatch_source_t compatibility
00045 void XDISPATCH_EXPORT _xdispatch_source_set_event_handler(dispatch_source_t, xdispatch::operation* op);
00046 void XDISPATCH_EXPORT _xdispatch_source_set_cancel_handler(dispatch_source_t, xdispatch::operation* op);
00047 
00048 #endif
00049 
00050 #if defined(XDISPATCH_HAS_LAMBDAS) && !defined(XDISPATCH_HAS_BLOCKS)
00051 
00052 inline void dispatch_async(dispatch_queue_t queue, const xdispatch::lambda_function& block){
00053     xdispatch::queue( queue ).async( block );
00054 }
00055 
00056 inline void dispatch_after(dispatch_time_t when, dispatch_queue_t queue, const xdispatch::lambda_function& block){
00057     xdispatch::queue( queue ).after( block, when );
00058 }
00059 
00060 inline void dispatch_sync(dispatch_queue_t queue, const xdispatch::lambda_function& block){
00061     xdispatch::queue( queue ).sync( block );
00062 }
00063 
00064 inline void dispatch_apply(size_t iterations, dispatch_queue_t queue, const xdispatch::iteration_lambda_function& block){
00065     xdispatch::queue( queue ).apply( block, iterations );
00066 }
00067 
00068 inline void dispatch_group_async(dispatch_group_t group, dispatch_queue_t queue, const xdispatch::lambda_function& block){
00069     xdispatch::group( group ).async( block, queue );
00070 }
00071 
00072 inline void dispatch_group_notify(dispatch_group_t group, dispatch_queue_t queue, const xdispatch::lambda_function& block){
00073     xdispatch::group( group ).notify( block, queue );
00074 }
00075 
00076 inline void dispatch_source_set_event_handler(dispatch_source_t source, const xdispatch::lambda_function& handler){
00077     _xdispatch_source_set_event_handler( source, new xdispatch::function_operation(handler) );
00078 }
00079 
00080 inline void dispatch_source_set_cancel_handler(dispatch_source_t source, const xdispatch::lambda_function& cancel_handler){
00081     _xdispatch_source_set_cancel_handler( source, new xdispatch::function_operation(cancel_handler) );
00082 }
00083 
00084 inline void dispatch_once(dispatch_once_t *predicate, const xdispatch::lambda_function& block){
00085     xdispatch::once o( predicate );
00086     o( block );
00087 }
00088 
00089 #endif
00090 
00093 #endif /* XDISPATCH_LAMBDA_DISPATCH_H_ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on Sun Oct 28 2012 22:12:47 for XDispatch by Doxygen 1.7.6.1
© 2010-2012 MLBA (about | privacy) All Rights reserved.