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 QITERATIONBLOCKRUNNABLE_H_
00024 #define QITERATIONBLOCKRUNNABLE_H_
00025 
00026 #include "qiterationrunnable.h"
00027 
00028 #include "qdispatchglobal.h"
00029 
00035 QT_BEGIN_HEADER
00036 QT_BEGIN_NAMESPACE
00037 
00038 QT_MODULE(Dispatch)
00039 
00040 #if XDISPATCH_HAS_BLOCKS
00041 
00048 class Q_DISPATCH_EXPORT QIterationBlockRunnable : public QIterationRunnable {
00049 
00050     public:
00058         QIterationBlockRunnable(dispatch_iteration_block_t b)
00059             : QIterationRunnable(), _block(Block_copy(b)) {}
00060         QIterationBlockRunnable(const QIterationBlockRunnable& other)
00061             : QIterationRunnable(other), _block(Block_copy(other._block)) {}
00062         virtual ~QIterationBlockRunnable() { Block_release(_block); }
00063 
00064         virtual inline void run(size_t index){
00065             _block(index);
00066         };
00067 
00068     private:
00069         dispatch_iteration_block_t _block;
00070 
00071 };
00072 #endif
00073 #if XDISPATCH_HAS_FUNCTION
00074 
00081 class Q_DISPATCH_EXPORT QIterationLambdaRunnable : public QIterationRunnable {
00082 
00083     public:
00091         QIterationLambdaRunnable(const xdispatch::iteration_lambda_function& b)
00092             : QIterationRunnable(), _function(b) {}
00093         QIterationLambdaRunnable(const QIterationLambdaRunnable& other)
00094             : QIterationRunnable(other), _function(other._function) {}
00095         virtual ~QIterationLambdaRunnable() { }
00096 
00097         virtual inline void run(size_t index){
00098             _function(index);
00099         }
00100 
00101     private:
00102         xdispatch::iteration_lambda_function _function;
00103 
00104 };
00105 #endif
00106 
00107 
00108 QT_END_NAMESPACE
00109 QT_END_HEADER
00110 
00113 #endif