Do not inherit WorkerDisposableTask from WorkerTask
WorkerDisposableTask is intended to be passed using auto_ptr, to make it plain that the ownership is moved. If it's inherited from WorkerTask it can be passed as a WorkerTask, which is confusing as it in that case will not be disposed of.
This commit is contained in:
parent
5de5609692
commit
6c4a4a3ee0
@ -47,11 +47,29 @@ public:
|
||||
* When the task has been executed, the instance will automatically be
|
||||
* deleted.
|
||||
*/
|
||||
class WorkerDisposableTask : public WorkerTask
|
||||
class WorkerDisposableTask
|
||||
{
|
||||
protected:
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
WorkerDisposableTask();
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
virtual ~WorkerDisposableTask();
|
||||
|
||||
/**
|
||||
* @brief Called in the context of a specific worker.
|
||||
*
|
||||
* @param worker The worker in whose context `execute` is called.
|
||||
*
|
||||
* @attention As the function is called by a worker, the body of `execute`
|
||||
* should execute quickly and not perform any blocking operations.
|
||||
*/
|
||||
virtual void execute(Worker& worker) = 0;
|
||||
|
||||
private:
|
||||
friend class Worker;
|
||||
|
||||
|
@ -33,6 +33,10 @@ WorkerDisposableTask::WorkerDisposableTask()
|
||||
{
|
||||
}
|
||||
|
||||
WorkerDisposableTask::~WorkerDisposableTask()
|
||||
{
|
||||
}
|
||||
|
||||
void WorkerDisposableTask::inc_ref()
|
||||
{
|
||||
atomic_add(&m_count, 1);
|
||||
|
Loading…
x
Reference in New Issue
Block a user