XDispatch 0.7.0
 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-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 #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     #ifdef XDISPATCH_HAS_BLOCKS
00079 
00085         inline void async(dispatch_block_t b) {
00086             async( new block_operation(b) );
00087         }
00088     #endif
00089 
00101         void apply(iteration_operation*, size_t times);
00102     #ifdef XDISPATCH_HAS_BLOCKS
00103 
00111         inline void apply(dispatch_iteration_block_t b, size_t times) {
00112             apply( new block_iteration_operation(b), times );
00113         }
00114     #endif
00115 
00126         void after(operation*, struct tm* time);
00127         void after(operation*, dispatch_time_t time);
00128     #ifdef XDISPATCH_HAS_BLOCKS
00129 
00134         inline void after(dispatch_block_t b, struct tm* time) {
00135             after( new block_operation(b), time );
00136         }
00137         inline void after(dispatch_block_t b, dispatch_time_t time) {
00138             after( new block_operation(b), time );
00139         }
00140     #endif
00141 
00149         void sync(operation*);
00150     #ifdef XDISPATCH_HAS_BLOCKS
00151 
00156         inline void sync(dispatch_block_t b) {
00157             sync( new block_operation(b) );
00158         }
00159     #endif
00160 
00173         void finalizer(operation*, const queue& = global_queue());
00174     #ifdef XDISPATCH_HAS_BLOCKS
00175 
00180         inline void finalizer(dispatch_block_t b, const queue& q = global_queue()) {
00181             finalizer( new block_operation(b), q );
00182         }
00183     #endif
00184 
00187         const std::string& label() const;
00194         virtual dispatch_object_t native() const;
00201         virtual dispatch_queue_t native_queue() const;
00202 
00203         queue& operator= (const queue&);
00204 
00205     private:
00206         class data;
00207         pointer<data>::unique d;
00208 
00209 };
00210 
00211 XDISPATCH_EXPORT std::ostream& operator<<(std::ostream&, const queue*);
00212 XDISPATCH_EXPORT std::ostream& operator<<(std::ostream&, const queue&);
00213 
00214 __XDISPATCH_END_NAMESPACE
00215 
00218 #endif /* XDISPATCH_QUEUE_H_ */

Generated on Tue Jun 12 2012 14:11:47 for XDispatch by Doxygen 1.8.0
© 2010-2012 MLBA (about | privacy) All Rights reserved.