kodi
Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
PLT_ThreadTask Class Reference

The PLT_ThreadTask class is a base class for executing a given task in a worker thread. More...

#include <PltThreadTask.h>

Inheritance diagram for PLT_ThreadTask:
Inheritance graph
[legend]
Collaboration diagram for PLT_ThreadTask:
Collaboration graph
[legend]

Public Member Functions

NPT_Result Kill ()
 When a task is not managed by a PLT_TaskManager, the owner must call this to stop and destroy it.
 

Protected Member Functions

virtual bool IsAborting (NPT_Timeout timeout)
 Return whether this task is in the process of stopping. More...
 
NPT_Result Start (PLT_TaskManager *task_manager=NULL, NPT_TimeInterval *delay=NULL, bool auto_destroy=true)
 Start a task by associating it with a task manager. More...
 
NPT_Result Stop (bool blocking=true)
 Stop the task. More...
 
virtual void DoInit ()
 This method to override in derived classes is called when the task is about to start.
 
virtual void DoAbort ()
 This method to override in derived classes is called when the task is about to stop.
 
virtual void DoRun ()
 This method to override in derived classes is the main task loop.
 
 PLT_ThreadTask ()
 A PLT_ThreadTask base class is never instantiated directly.
 
 ~PLT_ThreadTask () override
 The task manager will destroy the task when finished if m_AutoDestroy is true otherwise the owner of this task must use the Kill method.
 

Protected Attributes

PLT_TaskManagerm_TaskManager
 

Friends

class PLT_TaskManager
 

Detailed Description

The PLT_ThreadTask class is a base class for executing a given task in a worker thread.

A PLT_ThreadTask is usually always associated to a PLT_TaskManager which maintains a list to stop and destroy tasks when finished.

Member Function Documentation

◆ IsAborting()

virtual bool PLT_ThreadTask::IsAborting ( NPT_Timeout  timeout)
inlineprotectedvirtual

Return whether this task is in the process of stopping.

Parameters
timeoutnumber of milliseconds to wait
Returns
boolean indicating if the task is stopping

◆ Start()

NPT_Result PLT_ThreadTask::Start ( PLT_TaskManager task_manager = NULL,
NPT_TimeInterval delay = NULL,
bool  auto_destroy = true 
)
protected

Start a task by associating it with a task manager.

Parameters
task_managerPLT_TaskManager pointer
delayoptional time interval to wait before launching the new task
auto_destroya flag to indicate if the task is owned by someone else and thus should not destroy itself when done.

◆ Stop()

NPT_Result PLT_ThreadTask::Stop ( bool  blocking = true)
protected

Stop the task.

This is either called by a task manager or the Kill method.

Parameters
blockingWhether the method should block until the task has finished.

The documentation for this class was generated from the following files: