Changeset 162 in pacpusframework for branches/2.0-beta1/include/Pacpus/PacpusTools/AsyncWorkerBase.h
- Timestamp:
- 08/01/13 16:46:07 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.0-beta1/include/Pacpus/PacpusTools/AsyncWorkerBase.h
r89 r162 16 16 17 17 //#include <boost/noncopyable.hpp> 18 #include <Pacpus/PacpusTools/PacpusToolsConfig.h> 18 19 #include <QObject> 19 20 20 21 namespace pacpus 21 22 { 22 /** 23 * @brief A simple base class for asynchronous workers able to partake in the 24 * Qt slot / signal mechanism 25 * 26 * This class represents an asynchronous event-based worker able to receive and 27 * send Qt signals to other workers or threads. The rationale is to be able to 28 * define stateful objects that perform calculations asynchronously, triggered 29 * by external user-defined messages. 30 */ 31 class AsyncWorkerBase 23 24 /// A simple base class for asynchronous workers able to partake in the 25 /// Qt slot / signal mechanism 26 /// 27 /// This class represents an asynchronous event-based worker able to receive and 28 /// send Qt signals to other workers or threads. The rationale is to be able to 29 /// define stateful objects that perform calculations asynchronously, triggered 30 /// by external user-defined messages. 31 class PACPUSTOOLS_API AsyncWorkerBase 32 32 : public QObject 33 33 //, private boost::noncopyable 34 34 { 35 35 Q_OBJECT 36 Q_DISABLE_COPY(AsyncWorkerBase) 37 public: 38 /** Constructor. */ 36 Q_DISABLE_COPY(AsyncWorkerBase) 37 38 public: 39 /// Constructor. 39 40 AsyncWorkerBase(); 40 41 41 /** Destructor. */42 42 /// Destructor. 43 virtual ~AsyncWorkerBase(); 43 44 44 /**Starts the worker by creating a new thread for it, and calling the setup() virtual method. */45 45 /// Starts the worker by creating a new thread for it, and calling the setup() virtual method. */ 46 void start(); 46 47 47 /** Terminates the worker as soon as there are no more requests pending and its current processing 48 * is finished. 49 * 50 * This method tries to end the worker gracefully. All pending signals sent before the stop() request will 51 * be honored. 52 * It is safe to call this method from any thread. 53 * 54 * @param autoDelete if true, deletes the worker as soon as its event loop has finished processing. 55 */ 56 void stop(bool autoDelete); 48 /// Terminates the worker as soon as there are no more requests pending and its current processing 49 /// is finished. 50 /// 51 /// This method tries to end the worker gracefully. All pending signals sent before the stop() request will 52 /// be honored. 53 /// It is safe to call this method from any thread. 54 /// 55 /// @param autoDelete if true, deletes the worker as soon as its event loop has finished processing. 56 void stop(bool autoDelete); 57 57 58 /** Returns true if the worker is active. */ 59 bool isActive() const { return active_; } 58 /// @returns @b true if the worker is active, @b false otherwise. 59 bool isActive() const 60 { 61 return active_; 62 } 60 63 61 64 Q_SIGNALS: … … 73 76 virtual void cleanup(); 74 77 75 /** Returns true if the worker is stopping. */78 /// Returns true if the worker is stopping. 76 79 bool isStopping() const { return stopping_; } 77 80 … … 83 86 84 87 private: 85 /*! \brief Ends the worker, asking the underlying thread to terminate 86 * 87 * This method signals the end of processing and requests the underlying thread to terminate. Actual termination 88 * will occur as soon as all pending signals (including those that may come from other workers during the 89 * finish request handling) have been processed. 90 */ 88 /// Ends the worker, asking the underlying thread to terminate 89 /// 90 /// This method signals the end of processing and requests the underlying thread to terminate. Actual termination 91 /// will occur as soon as all pending signals (including those that may come from other workers during the 92 /// finish request handling) have been processed. 91 93 void finish(); 92 94 … … 95 97 bool stopping_; 96 98 }; 99 97 100 } // namespace pacpus 98 101
Note:
See TracChangeset
for help on using the changeset viewer.