| #pragma once |
| |
| #ifndef TTHREAD_H |
| #define TTHREAD_H |
| |
| #include "tsmartpointer.h" |
| |
| #include <QThread> |
| |
| #undef DVAPI |
| #undef DVVAR |
| #ifdef TNZCORE_EXPORTS |
| #define DVAPI DV_EXPORT_API |
| #define DVVAR DV_EXPORT_VAR |
| #else |
| #define DVAPI DV_IMPORT_API |
| #define DVVAR DV_IMPORT_VAR |
| #endif |
| |
| namespace TThread |
| { |
| |
| |
| |
| |
| void DVAPI init(); |
| |
| |
| |
| void DVAPI shutdown(); |
| |
| |
| |
| |
| class ExecutorId; |
| class Runnable; |
| |
| #if !(defined(MACOSX) || defined(LINUX)) |
| template class TSmartPointerT<Runnable>; |
| #endif |
| typedef TSmartPointerT<Runnable> RunnableP; |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| class DVAPI Runnable : public QObject, public TSmartObject |
| { |
| Q_OBJECT |
| DECLARE_CLASS_CODE |
| |
| ExecutorId *m_id; |
| |
| int m_load; |
| int m_schedulingPriority; |
| |
| friend class Executor; |
| friend class ExecutorImp; |
| friend class Worker; |
| |
| public: |
| Runnable(); |
| virtual ~Runnable(); |
| |
| |
| virtual void run() = 0; |
| |
| virtual int taskLoad(); |
| virtual int schedulingPriority(); |
| virtual QThread::Priority runningPriority(); |
| |
| Q_SIGNALS : |
| |
| void |
| started(TThread::RunnableP sender); |
| void finished(TThread::RunnableP sender); |
| void exception(TThread::RunnableP sender); |
| void canceled(TThread::RunnableP sender); |
| void terminated(TThread::RunnableP sender); |
| |
| public Q_SLOTS: |
| |
| virtual void onStarted(TThread::RunnableP sender); |
| virtual void onFinished(TThread::RunnableP sender); |
| virtual void onException(TThread::RunnableP sender); |
| virtual void onCanceled(TThread::RunnableP sender); |
| virtual void onTerminated(TThread::RunnableP sender); |
| |
| private: |
| inline bool needsAccumulation(); |
| inline bool customConditions(); |
| }; |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| class DVAPI Executor |
| { |
| ExecutorId *m_id; |
| |
| friend class ExecutorImp; |
| |
| public: |
| Executor(); |
| ~Executor(); |
| |
| static void init(); |
| static void shutdown(); |
| |
| void addTask(RunnableP task); |
| void removeTask(RunnableP task); |
| void cancelAll(); |
| |
| void setMaxActiveTasks(int count); |
| void setMaxActiveLoad(int load); |
| |
| int maxActiveTasks() const; |
| int maxActiveLoad() const; |
| |
| void setDedicatedThreads(bool dedicated, bool persistent = true); |
| |
| private: |
| |
| Executor &operator=(const Executor &); |
| Executor(const Executor &); |
| }; |
| |
| } |
| |
| #endif |