libassa
3.5.1
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
assa
TimerCountdown.h
Go to the documentation of this file.
1
// -*- c++ -*-
2
//------------------------------------------------------------------------------
3
// TimerCountdown.h
4
//------------------------------------------------------------------------------
5
// Copyright (c) 1999 by Vladislav Grinchenko
6
//
7
// This library is free software; you can redistribute it and/or
8
// modify it under the terms of the GNU Library General Public
9
// License as published by the Free Software Foundation; either
10
// version 2 of the License, or (at your option) any later version.
11
//------------------------------------------------------------------------------
12
// Created: 08/25/1999
13
//------------------------------------------------------------------------------
14
#ifndef TIMER_COUNTDOWN_H
15
#define TIMER_COUNTDOWN_H
16
17
#include "
assa/TimeVal.h
"
18
19
namespace
ASSA {
20
28
class
TimerCountdown
29
{
30
public
:
33
TimerCountdown
(
TimeVal
* wait_time_);
34
37
~TimerCountdown
();
38
39
private
:
41
TimeVal
*
m_maxWaitTime
;
42
44
TimeVal
m_start
;
45
};
46
47
//------------------------------------------------------------------------------
48
// inlines
49
//------------------------------------------------------------------------------
50
51
inline
52
TimerCountdown::
53
TimerCountdown
(
TimeVal
* wt_)
54
: m_maxWaitTime (wt_), m_start (
TimeVal
::gettimeofday ())
55
{
56
}
57
58
inline
59
TimerCountdown::
60
~TimerCountdown
()
61
{
62
if
(
m_maxWaitTime
== NULL)
63
return
;
64
65
TimeVal
elapsed (
TimeVal::gettimeofday
());
66
elapsed -=
m_start
;
67
68
if
( *
m_maxWaitTime
> elapsed )
69
*
m_maxWaitTime
-= elapsed;
70
else
71
*
m_maxWaitTime
=
TimeVal::zeroTime
();
72
}
73
74
}
// end namespace ASSA
75
76
#endif
/* TIMER_COUNTDOWN_H */
Generated on Tue Jun 19 2012 07:40:08 for libassa by
1.8.1.1