2014-08-18 10:17:16 +00:00
|
|
|
#ifndef PARALLELWORKER_H
|
|
|
|
#define PARALLELWORKER_H
|
|
|
|
|
|
|
|
#include "system_global.h"
|
|
|
|
|
|
|
|
namespace paysages {
|
|
|
|
namespace system {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Worker that can be used by the ParallelWork object to perform tasks in several threads.
|
|
|
|
*/
|
2015-11-09 21:30:46 +00:00
|
|
|
class SYSTEMSHARED_EXPORT ParallelWorker {
|
|
|
|
public:
|
2014-08-18 10:17:16 +00:00
|
|
|
ParallelWorker();
|
|
|
|
virtual ~ParallelWorker();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Abstract method to reimplement to process a work unit.
|
|
|
|
*
|
|
|
|
* This method will be called from any thread in the thread pool used by the ParallelWork.
|
|
|
|
*/
|
2014-08-19 09:44:54 +00:00
|
|
|
virtual void processParallelUnit(int unit) = 0;
|
2014-08-19 07:18:55 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Method to reimplement to know when to interrupt the processing of units.
|
|
|
|
*/
|
|
|
|
virtual void interrupt();
|
|
|
|
|
2015-11-09 21:30:46 +00:00
|
|
|
protected:
|
2014-08-19 07:18:55 +00:00
|
|
|
bool interrupted;
|
2014-08-18 10:17:16 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // PARALLELWORKER_H
|