Coverage Report

Created: 2025-11-16 09:57

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/vcl/source/app/timer.cxx
Line
Count
Source
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/*
3
 * This file is part of the LibreOffice project.
4
 *
5
 * This Source Code Form is subject to the terms of the Mozilla Public
6
 * License, v. 2.0. If a copy of the MPL was not distributed with this
7
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8
 *
9
 * This file incorporates work covered by the following license notice:
10
 *
11
 *   Licensed to the Apache Software Foundation (ASF) under one or more
12
 *   contributor license agreements. See the NOTICE file distributed
13
 *   with this work for additional information regarding copyright
14
 *   ownership. The ASF licenses this file to you under the Apache
15
 *   License, Version 2.0 (the "License"); you may not use this file
16
 *   except in compliance with the License. You may obtain a copy of
17
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
18
 */
19
20
#include <sal/log.hxx>
21
#include <vcl/timer.hxx>
22
#include <vcl/scheduler.hxx>
23
#include <schedulerimpl.hxx>
24
25
void Timer::SetDeletionFlags()
26
4.54k
{
27
    // If no AutoTimer, then stop.
28
4.54k
    if ( !mbAuto )
29
4.54k
        Task::SetDeletionFlags();
30
4.54k
}
31
32
sal_uInt64 Timer::UpdateMinPeriod( sal_uInt64 nTimeNow ) const
33
7.17k
{
34
7.17k
    sal_uInt64 nWakeupTime = GetSchedulerData()->mnUpdateTime + mnTimeout;
35
7.17k
    return ( nWakeupTime <= nTimeNow )
36
7.17k
        ? Scheduler::ImmediateTimeoutMs : nWakeupTime - nTimeNow;
37
7.17k
}
38
39
Timer::Timer( bool bAuto, const char *pDebugName )
40
6.14M
    : Task( pDebugName )
41
6.14M
    , mnTimeout( Scheduler::ImmediateTimeoutMs )
42
6.14M
    , mbAuto( bAuto )
43
6.14M
{
44
6.14M
    SetPriority( TaskPriority::DEFAULT );
45
6.14M
}
46
47
Timer::Timer( const char *pDebugName )
48
4.04M
    : Timer( false, pDebugName )
49
4.04M
{
50
4.04M
}
51
52
Timer::Timer( const Timer& rTimer )
53
3.90k
    : Timer( rTimer.mbAuto, rTimer.GetDebugName() )
54
3.90k
{
55
3.90k
    maInvokeHandler = rTimer.maInvokeHandler;
56
3.90k
    mnTimeout = rTimer.mnTimeout;
57
3.90k
}
58
59
Timer::~Timer()
60
6.12M
{
61
6.12M
}
62
63
Timer& Timer::operator=( const Timer& rTimer )
64
3.89k
{
65
3.89k
    Task::operator=( rTimer );
66
3.89k
    maInvokeHandler = rTimer.maInvokeHandler;
67
3.89k
    mnTimeout = rTimer.mnTimeout;
68
3.89k
    SAL_WARN_IF( mbAuto != rTimer.mbAuto, "vcl.schedule",
69
3.89k
        "Copying Timer with different mbAuto value!" );
70
3.89k
    return *this;
71
3.89k
}
72
73
void Timer::Invoke()
74
4.54k
{
75
4.54k
    maInvokeHandler.Call( this );
76
4.54k
}
77
78
void Timer::Invoke( Timer *arg )
79
0
{
80
0
    maInvokeHandler.Call( arg );
81
0
}
82
83
void Timer::Start(const bool bStartTimer)
84
53.2k
{
85
53.2k
    Task::Start(false);
86
53.2k
    if (bStartTimer)
87
53.2k
        Task::StartTimer(mnTimeout);
88
53.2k
}
89
90
void Timer::SetTimeout( sal_uInt64 nNewTimeout )
91
3.94M
{
92
3.94M
    mnTimeout = nNewTimeout;
93
    // If timer is active, then renew clock.
94
3.94M
    if ( IsActive() )
95
0
        StartTimer( mnTimeout );
96
3.94M
}
97
98
AutoTimer::AutoTimer( const char *pDebugName )
99
34.4k
    : Timer( true, pDebugName )
100
34.4k
{
101
34.4k
}
102
103
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */