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 
00023 #ifndef QBLOCKRUNNABLE_H_
00024 #define QBLOCKRUNNABLE_H_
00025 
00026 #include <QtCore/qrunnable.h>
00027 #include "qdispatchglobal.h"
00028 
00034 QT_BEGIN_HEADER
00035 QT_BEGIN_NAMESPACE
00036 
00037 QT_MODULE(Dispatch)
00038 
00039 #if XDISPATCH_HAS_BLOCKS
00040 
00047 class Q_DISPATCH_EXPORT QBlockRunnable : public QRunnable {
00048 
00049     public:
00057         QBlockRunnable(dispatch_block_t b)
00058             : QRunnable(), _block(Block_copy(b)) {}
00059         QBlockRunnable(const QBlockRunnable& other)
00060             : QRunnable(other), _block(Block_copy(other._block)) {}
00061         virtual ~QBlockRunnable() {
00062             Block_release(_block);
00063         }
00064 
00065         virtual void run(){
00066             _block();
00067         };
00068 
00069     private:
00070         dispatch_block_t _block;
00071 
00072 };
00073 #endif
00074 #if XDISPATCH_HAS_FUNCTION
00075 
00082 class Q_DISPATCH_EXPORT QLambdaRunnable : public QRunnable {
00083 
00084     public:
00092         QLambdaRunnable(const xdispatch::lambda_function& b)
00093             : QRunnable(), _function(b) {}
00094         QLambdaRunnable(const QLambdaRunnable& other)
00095             : QRunnable(other), _function(other._function) {}
00096         virtual ~QLambdaRunnable() {
00097           
00098         }
00099 
00100         virtual void run(){
00101             _function();
00102         }
00103 
00104     private:
00105         xdispatch::lambda_function _function;
00106 
00107 };
00108 #endif
00109 
00110 
00111 QT_END_NAMESPACE
00112 QT_END_HEADER
00113 
00116 #endif