LibreOffice Module vcl (master) 1
Public Member Functions | Protected Member Functions | Static Protected Member Functions | Private Attributes | Friends | List of all members
Task Class Referenceabstract

#include <task.hxx>

Inheritance diagram for Task:
[legend]
Collaboration diagram for Task:
[legend]

Public Member Functions

 Task (const char *pDebugName)
 
 Task (const Task &rTask)
 
virtual ~Task () COVERITY_NOEXCEPT_FALSE
 
Taskoperator= (const Task &rTask)
 
void SetPriority (TaskPriority ePriority)
 
TaskPriority GetPriority () const
 
const char * GetDebugName () const
 
virtual void Invoke ()=0
 
virtual void Start (bool bStartTimer=true)
 Schedules the task for execution. More...
 
void Stop ()
 
bool IsActive () const
 
void SetStatic ()
 This function must be called for static tasks, so the Task destructor ignores the scheduler mutex, as it may not be available anymore. More...
 
bool IsStatic () const
 

Protected Member Functions

const ImplSchedulerDataGetSchedulerData () const
 
virtual void SetDeletionFlags ()
 
virtual sal_uInt64 UpdateMinPeriod (sal_uInt64 nTimeNow) const =0
 How long (in MS) until the Task is ready to be dispatched? More...
 

Static Protected Member Functions

static void StartTimer (sal_uInt64 nMS)
 

Private Attributes

ImplSchedulerDatampSchedulerData
 Pointer to the element in scheduler list. More...
 
const char * mpDebugName
 Useful for debugging. More...
 
TaskPriority mePriority
 Task priority. More...
 
bool mbActive
 Currently in the scheduler. More...
 
bool mbStatic
 Is a static object. More...
 

Friends

class Scheduler
 
struct ImplSchedulerData
 

Detailed Description

Definition at line 42 of file task.hxx.

Constructor & Destructor Documentation

◆ Task() [1/2]

Task::Task ( const char *  pDebugName)

Definition at line 633 of file scheduler.cxx.

References DEFAULT, mbActive, and mpDebugName.

◆ Task() [2/2]

Task::Task ( const Task rTask)

Definition at line 643 of file scheduler.cxx.

References IsActive(), mbActive, mpDebugName, and Start().

◆ ~Task()

Task::~Task ( )
virtual

Member Function Documentation

◆ GetDebugName()

const char * Task::GetDebugName ( ) const
inline

◆ GetPriority()

TaskPriority Task::GetPriority ( ) const
inline

Definition at line 80 of file task.hxx.

References ImplSchedulerData::mePriority.

Referenced by AppendSchedulerData(), and Idle::Start().

◆ GetSchedulerData()

const ImplSchedulerData * Task::GetSchedulerData ( ) const
inlineprotected

Definition at line 56 of file task.hxx.

Referenced by Timer::UpdateMinPeriod().

◆ Invoke()

virtual void Task::Invoke ( )
pure virtual

Implemented in Timer, DebugEventInjector, and JSDialogNotifyIdle.

References Start, and Stop().

Referenced by Scheduler::CallbackTaskScheduling().

◆ IsActive()

bool Task::IsActive ( ) const
inline

◆ IsStatic()

bool Task::IsStatic ( ) const
inline

Definition at line 110 of file task.hxx.

Referenced by ~Task().

◆ operator=()

Task & Task::operator= ( const Task rTask)

Definition at line 616 of file scheduler.cxx.

References IsActive(), mbActive, mePriority, Start(), and Stop().

Referenced by Timer::operator=().

◆ SetDeletionFlags()

void Task::SetDeletionFlags ( )
protectedvirtual

Reimplemented in Timer.

Definition at line 549 of file scheduler.cxx.

References mbActive.

Referenced by Scheduler::CallbackTaskScheduling(), and Timer::SetDeletionFlags().

◆ SetPriority()

void Task::SetPriority ( TaskPriority  ePriority)

◆ SetStatic()

void Task::SetStatic ( )
inline

This function must be called for static tasks, so the Task destructor ignores the scheduler mutex, as it may not be available anymore.

The cleanup is still correct, as it has already happened in DeInitScheduler call well before the static destructor calls.

Definition at line 109 of file task.hxx.

Referenced by Scheduler::ImplDeInitScheduler().

◆ Start()

void Task::Start ( bool  bStartTimer = true)
virtual

Schedules the task for execution.

If the timer is already active, it's reset! Check with Task::IsActive() to prevent reset.

If you unset bStartTimer, the Task must call Task::StartTimer(...) to be correctly scheduled! Otherwise it might just be picked up when the Scheduler runs the next time.

Parameters
bStartTimerif false, don't schedule the Task by calling Task::StartTimer(0).

Reimplemented in Idle, and Timer.

Definition at line 554 of file scheduler.cxx.

References AppendSchedulerData(), tools::Time::GetSystemTicks(), ImplGetSVData(), ImplSchedulerData, ImplSVData::maSchedCtx, mbActive, ImplSchedulerContext::mbActive, ImplSchedulerData::mbInScheduler, mePriority, ImplSchedulerData::mePriority, ImplSchedulerData::mnUpdateTime, mpSchedulerData, ImplSchedulerData::mpTask, SAL_INFO, and StartTimer().

Referenced by operator=(), Idle::Start(), Timer::Start(), and Task().

◆ StartTimer()

void Task::StartTimer ( sal_uInt64  nMS)
staticprotected

◆ Stop()

void Task::Stop ( )

◆ UpdateMinPeriod()

virtual sal_uInt64 Task::UpdateMinPeriod ( sal_uInt64  nTimeNow) const
protectedpure virtual

How long (in MS) until the Task is ready to be dispatched?

Simply return Scheduler::ImmediateTimeoutMs if you're ready, like an Idle. If you have to return Scheduler::InfiniteTimeoutMs, you probably need another mechanism to wake up the Scheduler or rely on other Tasks to be scheduled, or simply use a polling Timer.

Parameters
nTimeNowthe current time
Returns
the sleep time of the Task to become ready

Implemented in Idle, and Timer.

Referenced by Scheduler::CallbackTaskScheduling().

Friends And Related Function Documentation

◆ ImplSchedulerData

friend struct ImplSchedulerData
friend

Definition at line 45 of file task.hxx.

Referenced by Start().

◆ Scheduler

friend class Scheduler
friend

Definition at line 44 of file task.hxx.

Member Data Documentation

◆ mbActive

bool Task::mbActive
private

Currently in the scheduler.

Definition at line 50 of file task.hxx.

Referenced by Scheduler::ImplDeInitScheduler(), operator=(), SetDeletionFlags(), SetPriority(), Start(), and Stop().

◆ mbStatic

bool Task::mbStatic
private

Is a static object.

Definition at line 51 of file task.hxx.

◆ mePriority

TaskPriority Task::mePriority
private

Task priority.

Definition at line 49 of file task.hxx.

Referenced by operator=(), SetPriority(), and Start().

◆ mpDebugName

const char* Task::mpDebugName
private

Useful for debugging.

Definition at line 48 of file task.hxx.

Referenced by Task().

◆ mpSchedulerData

ImplSchedulerData* Task::mpSchedulerData
private

Pointer to the element in scheduler list.

Definition at line 47 of file task.hxx.

Referenced by Scheduler::CallbackTaskScheduling(), Scheduler::ImplDeInitScheduler(), SetPriority(), Start(), Stop(), and ~Task().


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