1 /* Copyright (c) 2003, 2005 MySQL AB
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; version 2 of the License.
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 GNU General Public License for more details.
12 You should have received a copy of the GNU General Public License
13 along with this program; if not, write to the Free Software
14 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
18 * @brief A timer class that can't be fooled by NTP:ing the system clock to old time
26 Timer(NDB_TICKS delay_time
) {
31 * Set/Get alarm time of timer
33 inline void setDelay(NDB_TICKS delay_time
) { m_delay
= delay_time
; }
34 inline NDB_TICKS
getDelay() { return m_delay
; }
40 m_current_time
= NdbTick_CurrentMillisecond();
41 m_alarm_time
= m_current_time
+ m_delay
;
47 inline bool check() { return check(NdbTick_CurrentMillisecond()); }
49 inline bool check(NDB_TICKS check_time
) {
51 * Standard alarm check
53 if (check_time
> m_alarm_time
) return true;
56 * Time progressing, but it is not alarm time yet
58 if (check_time
>= m_current_time
) return false;
61 * Time has moved backwards
68 NDB_TICKS m_current_time
;
69 NDB_TICKS m_alarm_time
;