Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
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 #ifdef XDISPATCH_HAS_BLOCKS
00082
00086 inline void setHandler(dispatch_block_t b) {
00087 setHandler( new QBlockRunnable(b) );
00088 }
00089 #endif
00090
00096 void setLatency(int usec);
00101 static void singleShot(dispatch_time_t, const xdispatch::queue&, QRunnable*);
00106 static void singleShot(const QTime&, const xdispatch::queue&, QRunnable*);
00107 #ifdef XDISPATCH_HAS_BLOCKS
00108
00112 static void singleShot(dispatch_time_t t, const xdispatch::queue& q, dispatch_block_t b) {
00113 singleShot( t, q, new QBlockRunnable(b) );
00114 }
00119 static void singleShot(const QTime& t, const xdispatch::queue& q, dispatch_block_t b) {
00120 singleShot( t, q, new QBlockRunnable(b) );
00121 }
00122 #endif
00123 static QDispatchTimer* current();
00124
00125 bool operator ==(const QDispatchTimer&);
00126
00127 public slots:
00132 void start();
00137 void stop();
00138
00139 };
00140
00141 QT_END_NAMESPACE
00142 QT_END_HEADER
00143
00146 #endif