XDispatch 0.7.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
queue.h
Go to the documentation of this file.
00001 
00002 /*
00003 * Copyright (c) 2011-2013 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 #ifndef XDISPATCH_QUEUE_H_
00024 #define XDISPATCH_QUEUE_H_
00025 
00031 #ifndef __XDISPATCH_INDIRECT__
00032 #error "Please #include <xdispatch/dispatch.h> instead of this file directly."
00033 #endif
00034 
00035 #include <iostream>
00036 
00037 __XDISPATCH_BEGIN_NAMESPACE
00038 
00050 class XDISPATCH_EXPORT queue : public object {
00051 
00052     public:
00057         queue(dispatch_queue_t);
00062         queue(const char* label);
00063         queue(const std::string&);
00064         queue(const queue&);
00065         ~queue();
00066 
00077         void async(operation*);
00078     #if XDISPATCH_HAS_BLOCKS
00079 
00085         inline void async(dispatch_block_t b) {
00086             async( new block_operation(b) );
00087         }
00088     #endif
00089     #if XDISPATCH_HAS_FUNCTION
00090 
00096         inline void async(const lambda_function& b) {
00097             async( new function_operation(b) );
00098         }
00099     #endif
00100 
00112         void apply(iteration_operation*, size_t times);
00113     #if XDISPATCH_HAS_BLOCKS
00114 
00122         inline void apply(dispatch_iteration_block_t b, size_t times) {
00123             apply( new block_iteration_operation(b), times );
00124         }
00125     #endif
00126     #if XDISPATCH_HAS_FUNCTION
00127 
00135         inline void apply(const iteration_lambda_function& b, size_t times) {
00136             apply( new function_iteration_operation(b), times );
00137         }
00138     #endif
00139 
00150         void after(operation*, struct tm* time);
00151         void after(operation*, dispatch_time_t time);
00152     #if XDISPATCH_HAS_BLOCKS
00153 
00158         inline void after(dispatch_block_t b, struct tm* time) {
00159             after( new block_operation(b), time );
00160         }
00161         inline void after(dispatch_block_t b, dispatch_time_t time) {
00162             after( new block_operation(b), time );
00163         }
00164     #endif
00165     #if XDISPATCH_HAS_FUNCTION
00166 
00171         inline void after(const lambda_function& b, struct tm* time) {
00172             after( new function_operation(b), time );
00173         }
00174         inline void after(const lambda_function& b, dispatch_time_t time) {
00175             after( new function_operation(b), time );
00176         }
00177     #endif
00178 
00186         void sync(operation*);
00187     #if XDISPATCH_HAS_BLOCKS
00188 
00193         inline void sync(dispatch_block_t b) {
00194             sync( new block_operation(b) );
00195         }
00196     #endif
00197     #if XDISPATCH_HAS_FUNCTION
00198 
00203         inline void sync(const lambda_function& b) {
00204             sync( new function_operation(b) );
00205         }
00206     #endif
00207 
00220         void finalizer(operation*, const queue& = global_queue());
00221     #if XDISPATCH_HAS_BLOCKS
00222 
00227         inline void finalizer(dispatch_block_t b, const queue& q = global_queue()) {
00228             finalizer( new block_operation(b), q );
00229         }
00230     #endif
00231     #if XDISPATCH_HAS_FUNCTION
00232 
00237         inline void finalizer(const lambda_function& b, const queue& q = global_queue()) {
00238             finalizer( new function_operation(b), q );
00239         }
00240     #endif
00241 
00244         const std::string& label() const;
00251         virtual dispatch_object_t native() const;
00258         virtual dispatch_queue_t native_queue() const;
00259 
00260         queue& operator= (const queue&);
00261 
00262     private:
00263         class data;
00264         pointer<data>::unique d;
00265 
00266 };
00267 
00268 XDISPATCH_EXPORT std::ostream& operator<<(std::ostream&, const queue*);
00269 XDISPATCH_EXPORT std::ostream& operator<<(std::ostream&, const queue&);
00270 
00271 __XDISPATCH_END_NAMESPACE
00272 
00275 #endif /* XDISPATCH_QUEUE_H_ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on Sun Jan 27 2013 21:21:52 for XDispatch by Doxygen 1.7.6.1
© 2010-2013 MLBA (about | privacy) All Rights reserved.