rambrain
timer.h
Go to the documentation of this file.
1 /* rambrain - a dynamical physical memory extender
2  * Copyright (C) 2015 M. Imgrund, A. Arth
3  * mimgrund (at) mpifr-bonn.mpg.de
4  * arth (at) usm.uni-muenchen.de
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef TIMER_H
21 #define TIMER_H
22 
23 #include <time.h>
24 #include <stdio.h>
25 #include <string.h>
26 #include <sys/signal.h>
27 
28 namespace rambrain
29 {
30 
35 class Timer
36 {
37 
38 public:
39 
45  static void startTimer ( long seconds, long nanoseconds );
49  static void stopTimer();
50 
54  static inline bool isRunning() {
55  return running;
56  }
57 
58 private:
63  Timer();
64 
68  static void initialiseTimer();
69 
70  static timer_t timerid;
71  static struct sigevent sev;
72  static struct itimerspec its;
73 
74  static bool initialised, running;
75 
76 };
77 
78 }
79 
80 #endif // TIMER_H
81 
static bool isRunning()
Simple getter.
Definition: timer.h:54
static void stopTimer()
Stop the timer.
Definition: timer.cpp:56
static void initialiseTimer()
Set up the timer.
Definition: timer.cpp:66
static struct itimerspec its
Definition: timer.h:72
static timer_t timerid
Definition: timer.h:70
static bool initialised
Definition: timer.h:74
static struct sigevent sev
Definition: timer.h:71
Provides an interface to a timer which periodically sends SIGUSR1 signals.
Definition: timer.h:35
static void startTimer(long seconds, long nanoseconds)
Start the timer.
Definition: timer.cpp:36
Timer()
Create a new timer.
Definition: timer.cpp:32
static bool running
Definition: timer.h:74