LibreOffice Module vcl (master) 1
Public Member Functions | Protected Member Functions | Private Attributes | List of all members
Timer Class Reference

#include <timer.hxx>

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

Public Member Functions

 Timer (const char *pDebugName)
 
 Timer (const Timer &rTimer)
 
virtual ~Timer () override
 
Timeroperator= (const Timer &rTimer)
 
virtual void Invoke () override
 Calls the maInvokeHandler with the parameter this. More...
 
void Invoke (Timer *arg)
 Calls the maInvokeHandler with the parameter. More...
 
void SetInvokeHandler (const Link< Timer *, void > &rLink)
 
void ClearInvokeHandler ()
 
void SetTimeout (sal_uInt64 nTimeoutMs)
 
sal_uInt64 GetTimeout () const
 
virtual void Start (bool bStartTimer=true) override
 Schedules the task for execution. More...
 
- Public Member Functions inherited from Task
 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

virtual void SetDeletionFlags () override
 
virtual sal_uInt64 UpdateMinPeriod (sal_uInt64 nTimeNow) const override
 How long (in MS) until the Task is ready to be dispatched? More...
 
 Timer (bool bAuto, const char *pDebugName)
 
- Protected Member Functions inherited from Task
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...
 

Private Attributes

Link< Timer *, void > maInvokeHandler
 Callback Link. More...
 
sal_uInt64 mnTimeout
 
const bool mbAuto
 

Additional Inherited Members

- Static Protected Member Functions inherited from Task
static void StartTimer (sal_uInt64 nMS)
 

Detailed Description

Definition at line 26 of file timer.hxx.

Constructor & Destructor Documentation

◆ Timer() [1/3]

Timer::Timer ( bool  bAuto,
const char *  pDebugName 
)
protected

Definition at line 39 of file timer.cxx.

References DEFAULT, and Task::SetPriority().

◆ Timer() [2/3]

Timer::Timer ( const char *  pDebugName)

Definition at line 47 of file timer.cxx.

◆ Timer() [3/3]

Timer::Timer ( const Timer rTimer)

Definition at line 52 of file timer.cxx.

References maInvokeHandler, and mnTimeout.

◆ ~Timer()

Timer::~Timer ( )
overridevirtual

Definition at line 59 of file timer.cxx.

Member Function Documentation

◆ ClearInvokeHandler()

void Timer::ClearInvokeHandler ( )
inline

Definition at line 57 of file timer.hxx.

◆ GetTimeout()

sal_uInt64 Timer::GetTimeout ( ) const
inline

Definition at line 60 of file timer.hxx.

◆ Invoke() [1/2]

void Timer::Invoke ( )
overridevirtual

Calls the maInvokeHandler with the parameter this.

Implements Task.

Reimplemented in DebugEventInjector, and JSDialogNotifyIdle.

Definition at line 73 of file timer.cxx.

References Link< typename Arg, typename Ret >::Call(), and maInvokeHandler.

Referenced by IdleFormatter::DoIdleFormat(), and IdleFormatter::ForceTimeout().

◆ Invoke() [2/2]

void Timer::Invoke ( Timer arg)

Calls the maInvokeHandler with the parameter.

Convenience Invoke function, mainly used to call with nullptr.

Parameters
argparameter for the Link::Call function

Definition at line 78 of file timer.cxx.

References Link< typename Arg, typename Ret >::Call(), and maInvokeHandler.

◆ operator=()

Timer & Timer::operator= ( const Timer rTimer)

Definition at line 63 of file timer.cxx.

References maInvokeHandler, mbAuto, mnTimeout, Task::operator=(), and SAL_WARN_IF.

◆ SetDeletionFlags()

void Timer::SetDeletionFlags ( )
overrideprotectedvirtual

Reimplemented from Task.

Definition at line 25 of file timer.cxx.

References mbAuto, and Task::SetDeletionFlags().

◆ SetInvokeHandler()

void Timer::SetInvokeHandler ( const Link< Timer *, void > &  rLink)
inline

◆ SetTimeout()

void Timer::SetTimeout ( sal_uInt64  nTimeoutMs)

◆ Start()

void Timer::Start ( bool  bStartTimer = true)
overridevirtual

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 from Task.

Reimplemented in Idle.

Definition at line 83 of file timer.cxx.

References mnTimeout, Task::Start(), and Task::StartTimer().

Referenced by MenuBarUpdateIconManager::AddMenuBarIcon(), MenuFloatingWindow::ChangeHighlightItem(), DebugEventInjector::DebugEventInjector(), SalFlashAttention::Flash(), weld::IMPL_LINK(), Animation::ImplRestartTimer(), MenuFloatingWindow::ImplScroll(), DebugEventInjector::Invoke(), vcl::graphic::Manager::Manager(), SpinField::MouseButtonDown(), SpinField::MouseMove(), MenuFloatingWindow::MouseMove(), HelpTextWindow::ResetHideTimer(), SelectionEngine::SelMouseMove(), SelectionEngine::SetUpdateInterval(), HelpTextWindow::ShowHelp(), and SalFlashAttention::Start().

◆ UpdateMinPeriod()

sal_uInt64 Timer::UpdateMinPeriod ( sal_uInt64  nTimeNow) const
overrideprotectedvirtual

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

Implements Task.

Reimplemented in Idle.

Definition at line 32 of file timer.cxx.

References Task::GetSchedulerData(), Scheduler::ImmediateTimeoutMs, mnTimeout, and ImplSchedulerData::mnUpdateTime.

Member Data Documentation

◆ maInvokeHandler

Link<Timer *, void> Timer::maInvokeHandler
private

Callback Link.

Definition at line 28 of file timer.hxx.

Referenced by Invoke(), operator=(), and Timer().

◆ mbAuto

const bool Timer::mbAuto
private

Definition at line 30 of file timer.hxx.

Referenced by operator=(), and SetDeletionFlags().

◆ mnTimeout

sal_uInt64 Timer::mnTimeout
private

Definition at line 29 of file timer.hxx.

Referenced by operator=(), SetTimeout(), Start(), Timer(), and UpdateMinPeriod().


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