1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <tools/time.hxx>
21 #include <vcl/timer.hxx>
22 #include "saltimer.hxx"
24 void Timer::SetDeletionFlags()
26 // If no AutoTimer, then stop.
29 mpSchedulerData
->mbDelete
= true;
34 bool Timer::ReadyForSchedule( bool /* bTimerOnly */, sal_uInt64 nTimeNow
) const
36 return (mpSchedulerData
->mnUpdateTime
+ mnTimeout
) <= nTimeNow
;
39 bool Timer::IsIdle() const
44 sal_uInt64
Timer::UpdateMinPeriod( sal_uInt64 nMinPeriod
, sal_uInt64 nTime
) const
46 sal_uInt64 nDeltaTime
;
47 //determine smallest time slot
48 if( mpSchedulerData
->mnUpdateTime
== nTime
)
50 nDeltaTime
= mnTimeout
;
51 if( nDeltaTime
< nMinPeriod
)
52 nMinPeriod
= nDeltaTime
;
56 nDeltaTime
= mpSchedulerData
->mnUpdateTime
+ mnTimeout
;
57 if( nDeltaTime
< nTime
)
58 nMinPeriod
= ImmediateTimeoutMs
;
62 if( nDeltaTime
< nMinPeriod
)
63 nMinPeriod
= nDeltaTime
;
70 Timer::Timer(const sal_Char
*pDebugName
) :
71 Scheduler(pDebugName
),
72 mnTimeout(ImmediateTimeoutMs
),
75 mePriority
= SchedulerPriority::HIGHEST
;
78 Timer::Timer( const Timer
& rTimer
) :
80 mnTimeout(rTimer
.mnTimeout
),
83 maTimeoutHdl
= rTimer
.maTimeoutHdl
;
88 maTimeoutHdl
.Call( this );
94 Scheduler::ImplStartTimer(mnTimeout
);
97 void Timer::SetTimeout( sal_uInt64 nNewTimeout
)
99 mnTimeout
= nNewTimeout
;
100 // If timer is active, then renew clock.
103 Scheduler::ImplStartTimer(mnTimeout
);
107 Timer
& Timer::operator=( const Timer
& rTimer
)
109 Scheduler::operator=(rTimer
);
110 maTimeoutHdl
= rTimer
.maTimeoutHdl
;
111 mnTimeout
= rTimer
.mnTimeout
;
112 mbAuto
= rTimer
.mbAuto
;
116 AutoTimer::AutoTimer( const sal_Char
*pDebugName
)
117 : Timer( pDebugName
)
122 AutoTimer::AutoTimer( const AutoTimer
& rTimer
) : Timer( rTimer
)
127 AutoTimer
& AutoTimer::operator=( const AutoTimer
& rTimer
)
129 Timer::operator=( rTimer
);
132 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */