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

Helper class primary used to track time of long running iterating tasks. More...

#include <TaskStopwatch.hxx>

Public Member Functions

 TaskStopwatch (bool bConciderLastIterTime=true)
 Per default the watch considers the last iter time when asking for an other iteration, so considers Scheduler::acceptableTaskTime as a maximum value. More...
 
bool exceededRuntime ()
 Returns true, if the time slot is already exceeded. More...
 
bool continueIter ()
 Returns true, if another iteration will probably pass in the time slot. More...
 
void reset ()
 Reset the stopwatch. More...
 
void setInputStop (VclInputFlags eInputStop=eDefaultInputStop)
 Sets the input events, which should also "exceed" the stopwatch. More...
 
VclInputFlags inputStop () const
 

Static Public Member Functions

static unsigned int timeSlice ()
 Sets the time considered the acceptable maximum for a task to run. More...
 
static void setTimeSlice (unsigned int nTimeSlice)
 

Private Member Functions

bool nextIter (bool bQueryOnly)
 

Private Attributes

sal_uInt64 m_nStartTicks
 
sal_uInt64 m_nIterStartTicks
 
bool m_bConsiderLastIterTime
 
VclInputFlags m_eInputStop
 

Static Private Attributes

static constexpr VclInputFlags eDefaultInputStop = VCL_INPUT_ANY & ~VclInputFlags::TIMER
 
static constexpr unsigned int nDefaultTimeSlice = 50
 
static unsigned int m_nTimeSlice = TaskStopwatch::nDefaultTimeSlice
 

Detailed Description

Helper class primary used to track time of long running iterating tasks.

Normally it should be sufficient to instantiate the watch object before starting the iteration and query continueIter() at the end of each.

Called Stopwatch, because there is already a Timer class in the Scheduler.

TODO: merge into the general Scheduler, so this can also be used to track Task runtimes in a more general way. TODO: handle fast iterations, where continueIter is called multiple times per tick, by counting the iterations per tick and use that for appoximation.

Definition at line 31 of file TaskStopwatch.hxx.

Constructor & Destructor Documentation

TaskStopwatch::TaskStopwatch ( bool  bConciderLastIterTime = true)
inline

Per default the watch considers the last iter time when asking for an other iteration, so considers Scheduler::acceptableTaskTime as a maximum value.

If you already know your iter time vary in a large range, consider setting bConciderLastIterTime to false, so Scheduler::acceptableTaskTime will be used as a minimum time slot.

Definition at line 76 of file TaskStopwatch.hxx.

References Time.

Member Function Documentation

bool TaskStopwatch::continueIter ( )
inline

Returns true, if another iteration will probably pass in the time slot.

Definition at line 92 of file TaskStopwatch.hxx.

bool TaskStopwatch::exceededRuntime ( )
inline

Returns true, if the time slot is already exceeded.

Definition at line 87 of file TaskStopwatch.hxx.

VclInputFlags TaskStopwatch::inputStop ( ) const
inline

Definition at line 109 of file TaskStopwatch.hxx.

bool TaskStopwatch::nextIter ( bool  bQueryOnly)
inlineprivate

Definition at line 42 of file TaskStopwatch.hxx.

References Application::AnyInput(), and tools::Time::GetSystemTicks().

void TaskStopwatch::reset ( )
inline

Reset the stopwatch.

Definition at line 97 of file TaskStopwatch.hxx.

References tools::Time::GetSystemTicks().

void TaskStopwatch::setInputStop ( VclInputFlags  eInputStop = eDefaultInputStop)
inline

Sets the input events, which should also "exceed" the stopwatch.

Per default this ignores the VclInputFlags::TIMER.

Definition at line 108 of file TaskStopwatch.hxx.

static void TaskStopwatch::setTimeSlice ( unsigned int  nTimeSlice)
inlinestatic

Definition at line 118 of file TaskStopwatch.hxx.

static unsigned int TaskStopwatch::timeSlice ( )
inlinestatic

Sets the time considered the acceptable maximum for a task to run.

This is an orientation for long time background jobs to yield to the scheduler, so Idle task don't starve each other too much.

Definition at line 117 of file TaskStopwatch.hxx.

Member Data Documentation

constexpr VclInputFlags TaskStopwatch::eDefaultInputStop = VCL_INPUT_ANY & ~VclInputFlags::TIMER
staticprivate

Definition at line 33 of file TaskStopwatch.hxx.

bool TaskStopwatch::m_bConsiderLastIterTime
private

Definition at line 39 of file TaskStopwatch.hxx.

VclInputFlags TaskStopwatch::m_eInputStop
private

Definition at line 40 of file TaskStopwatch.hxx.

sal_uInt64 TaskStopwatch::m_nIterStartTicks
private

Definition at line 38 of file TaskStopwatch.hxx.

sal_uInt64 TaskStopwatch::m_nStartTicks
private

Definition at line 37 of file TaskStopwatch.hxx.

unsigned int TaskStopwatch::m_nTimeSlice = TaskStopwatch::nDefaultTimeSlice
staticprivate

Definition at line 35 of file TaskStopwatch.hxx.

constexpr unsigned int TaskStopwatch::nDefaultTimeSlice = 50
staticprivate

Definition at line 34 of file TaskStopwatch.hxx.


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