1 /* timer.cc
2  *
3  * Copyright (C) 2002 The gtkmm Development Team
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #include <glibmm.h>
20 #include <glib.h>
21 
22 namespace Glib
23 {
24 
Timer()25 Timer::Timer() : gobject_(g_timer_new())
26 {
27 }
28 
~Timer()29 Timer::~Timer() noexcept
30 {
31   g_timer_destroy(gobject_);
32 }
33 
34 void
start()35 Timer::start()
36 {
37   g_timer_start(gobject_);
38 }
39 
40 void
stop()41 Timer::stop()
42 {
43   g_timer_stop(gobject_);
44 }
45 
46 void
reset()47 Timer::reset()
48 {
49   g_timer_reset(gobject_);
50 }
51 
52 double
elapsed() const53 Timer::elapsed() const
54 {
55   return g_timer_elapsed(gobject_, nullptr);
56 }
57 
58 double
elapsed(unsigned long & microseconds) const59 Timer::elapsed(unsigned long& microseconds) const
60 {
61   return g_timer_elapsed(gobject_, &microseconds);
62 }
63 
64 void
usleep(unsigned long microseconds)65 usleep(unsigned long microseconds)
66 {
67   g_usleep(microseconds);
68 }
69 
70 } // namespace Glib
71