XDispatch 0.7.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
qdispatchtimer.h
Go to the documentation of this file.
00001 /*
00002 * Copyright (c) 2011-2013 MLBA-Team. 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 #ifndef QDISPATCH_TIMER_H_
00023 #define QDISPATCH_TIMER_H_
00024 
00025 #include "qdispatchglobal.h"
00026 #include "qblockrunnable.h"
00027 
00028 #include <QtCore/qobject.h>
00029 
00035 QT_BEGIN_HEADER
00036 QT_BEGIN_NAMESPACE
00037 
00038 class QTime;
00039 class QRunnable;
00040 
00041 QT_MODULE(Dispatch)
00042 
00043 
00052 class Q_DISPATCH_EXPORT QDispatchTimer : public QObject, private xdispatch::timer {
00053 
00054         Q_OBJECT
00055 
00056     public:
00064         QDispatchTimer(int msec, QObject* parent = NULL);
00065         QDispatchTimer(const QDispatchTimer&);
00066         QDispatchTimer(const xdispatch::timer&, QObject* parent = NULL);
00067         ~QDispatchTimer();
00071         void setInterval(int msec);
00075         void setTargetQueue(const xdispatch::queue&);
00080         void setHandler(QRunnable*);
00081   #if XDISPATCH_HAS_BLOCKS
00082 
00086         inline void setHandler(dispatch_block_t b) {
00087             setHandler( new QBlockRunnable(b) );
00088         }
00089   #endif
00090   #if XDISPATCH_HAS_FUNCTION
00091 
00095         inline void setHandler(const xdispatch::lambda_function& b) {
00096             setHandler( new QLambdaRunnable(b) );
00097         }
00098   #endif
00099 
00105         void setLatency(int usec);
00110         static void singleShot(dispatch_time_t, const xdispatch::queue&, QRunnable*);
00115         static void singleShot(const QTime&, const xdispatch::queue&, QRunnable*);
00116   #if XDISPATCH_HAS_BLOCKS
00117 
00121         static void singleShot(dispatch_time_t t, const xdispatch::queue& q, dispatch_block_t b) {
00122             singleShot( t, q, new QBlockRunnable(b) );
00123         }
00128         static void singleShot(const QTime& t, const xdispatch::queue& q, dispatch_block_t b) {
00129             singleShot( t, q, new QBlockRunnable(b) );
00130         }
00131   #endif
00132   #if XDISPATCH_HAS_BLOCKS
00133 
00137         static void singleShot(dispatch_time_t t, const xdispatch::queue& q, const xdispatch::lambda_function& b) {
00138             singleShot( t, q, new QLambdaRunnable(b) );
00139         }
00144         static void singleShot(const QTime& t, const xdispatch::queue& q, const xdispatch::lambda_function& b) {
00145             singleShot( t, q, new QLambdaRunnable(b) );
00146         }
00147   #endif
00148         static QDispatchTimer* current();
00149 
00150         bool operator ==(const QDispatchTimer&);
00151 
00152     public slots:
00157         void start();
00162         void stop();
00163 
00164 };
00165 
00166 QT_END_NAMESPACE
00167 QT_END_HEADER
00168 
00171 #endif /* QDISPATCH_SEMAPHORE_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.