00001 /* 00002 * Copyright (c) 2011 MLBA. All rights reserved. 00003 * 00004 * @MLBA_OPEN_LICENSE_HEADER_START@ 00005 * 00006 * Licensed under the Apache License, Version 2.0 (the "License"); 00007 * you may not use this file except in compliance with the License. 00008 * You may obtain a copy of the License at 00009 * 00010 * http://www.apache.org/licenses/LICENSE-2.0 00011 * 00012 * Unless required by applicable law or agreed to in writing, software 00013 * distributed under the License is distributed on an "AS IS" BASIS, 00014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00015 * See the License for the specific language governing permissions and 00016 * limitations under the License. 00017 * 00018 * @MLBA_OPEN_LICENSE_HEADER_END@ 00019 */ 00020 00021 00022 00023 #ifndef QDISPATCH_GROUP_H_ 00024 #define QDISPATCH_GROUP_H_ 00025 00026 #include <QObject> 00027 #include "qdispatchglobal.h" 00028 #include "../xdispatch/dispatch.h" 00029 00030 QT_BEGIN_HEADER 00031 QT_BEGIN_NAMESPACE 00032 00033 class QRunnable; 00034 class QDispatchQueue; 00035 class QTime; 00036 00037 QT_MODULE(Dispatch) 00038 00039 00049 class Q_DISPATCH_EXPORT QDispatchGroup : public QObject, public xdispatch::group { 00050 00051 Q_OBJECT 00052 00053 public: 00057 QDispatchGroup(); 00058 QDispatchGroup(dispatch_group_t); 00059 QDispatchGroup(const QDispatchGroup&); 00060 QDispatchGroup(const xdispatch::group&); 00061 ~QDispatchGroup(); 00062 00068 void async(QRunnable* r, const xdispatch::queue& = xdispatch::global_queue()); 00069 void async(xdispatch::operation*, const xdispatch::queue& = xdispatch::global_queue()); 00070 #ifdef XDISPATCH_HAS_BLOCKS 00071 void async(dispatch_block_t b, const xdispatch::queue& = xdispatch::global_queue()); 00072 #endif 00073 00079 bool wait(const QTime& t); 00080 using xdispatch::group::wait; 00093 void notify(QRunnable* r, const xdispatch::queue& = xdispatch::global_queue()); 00097 void notify(xdispatch::operation*, const xdispatch::queue& = xdispatch::global_queue()); 00098 #ifdef XDISPATCH_HAS_BLOCKS 00099 00102 void notify(dispatch_block_t, const xdispatch::queue& = xdispatch::global_queue()); 00103 #endif 00104 00105 public slots: 00106 void resume(); 00107 void suspend(); 00108 00109 signals: 00117 void allFinished(); 00118 00119 private: 00120 00121 friend Q_DECL_EXPORT QDebug operator<<(QDebug, const QDispatchGroup&); 00122 00123 class Private; 00124 Private* d; 00125 }; 00126 00127 Q_DECL_EXPORT QDebug operator<<(QDebug, const QDispatchGroup&); 00128 00129 QT_END_NAMESPACE 00130 QT_END_HEADER 00131 00132 #endif /* QDISPATCH_GROUP_H_ */