1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
|
<html>
<head>
<title>~/src/firstworks/rudiments-0.31/include/rudiments/intervaltimer.h.html</title>
<meta name="Generator" content="Vim/7.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body bgcolor="#ffffff" text="#000000">
<pre>
<font color="#0000ff">// Copyright (c) 2004 David Muse</font>
<font color="#0000ff">// See the COPYING file for more information.</font>
<font color="#a020f0">#ifndef RUDIMENTS_INTERVALTIMER_H</font>
<font color="#a020f0">#define RUDIMENTS_INTERVALTIMER_H</font>
<font color="#a020f0">#include </font><font color="#ff00ff"><rudiments/private/intervaltimerincludes.h></font>
<font color="#0000ff">// The intervaltimer class provides methods for interfacing with</font>
<font color="#0000ff">// interval timers.</font>
<font color="#a020f0">#ifdef RUDIMENTS_NAMESPACE</font>
<font color="#2e8b57"><b>namespace</b></font> rudiments {
<font color="#a020f0">#endif</font>
<font color="#2e8b57"><b>class</b></font> intervaltimerprivate;
<font color="#2e8b57"><b>class</b></font> intervaltimer {
<font color="#a52a2a"><b>public</b></font>:
intervaltimer(<font color="#2e8b57"><b>int</b></font> which);
<font color="#0000ff">// Initialize the interval timer. "which" must be one</font>
<font color="#0000ff">// of:</font>
<font color="#0000ff">// ITIMER_REAL - decrements in real time, raises SIGALRM</font>
<font color="#0000ff">// ITIMER_VIRTUAL - decrements when the process is</font>
<font color="#0000ff">// executing but not during system</font>
<font color="#0000ff">// calls, raises SIGVTALRM</font>
<font color="#0000ff">// ITIMER_PROF - decrements when the process is </font>
<font color="#0000ff">// executing or and during system</font>
<font color="#0000ff">// calls, raises SIGPROF</font>
~intervaltimer();
<font color="#2e8b57"><b>void</b></font> initialize();
<font color="#0000ff">// Sets (or resets) the initial and periodic intervals</font>
<font color="#0000ff">// to 0 seconds and 0 microseconds.</font>
<font color="#2e8b57"><b>void</b></font> setInitialInterval(<font color="#2e8b57"><b>long</b></font> seconds, <font color="#2e8b57"><b>long</b></font> microseconds);
<font color="#0000ff">// Set the timer's initial interval to "seconds"</font>
<font color="#0000ff">// seconds and "microseconds" microseconds.</font>
<font color="#2e8b57"><b>void</b></font> setInitialInterval(<font color="#2e8b57"><b>const</b></font> timeval *tv);
<font color="#0000ff">// Set the timer's initial interval to seconds and</font>
<font color="#0000ff">// microseconds specified in "tv".</font>
<font color="#2e8b57"><b>void</b></font> setPeriodicInterval(<font color="#2e8b57"><b>long</b></font> seconds, <font color="#2e8b57"><b>long</b></font> microseconds);
<font color="#0000ff">// Set the timer's periodic interval to "seconds"</font>
<font color="#0000ff">// seconds and "microseconds" microseconds.</font>
<font color="#2e8b57"><b>void</b></font> setPeriodicInterval(<font color="#2e8b57"><b>const</b></font> timeval *tv);
<font color="#0000ff">// Set the timer's periodic interval to seconds and</font>
<font color="#0000ff">// microseconds specified in "tv".</font>
<font color="#2e8b57"><b>void</b></font> setIntervals(<font color="#2e8b57"><b>long</b></font> seconds, <font color="#2e8b57"><b>long</b></font> microseconds);
<font color="#0000ff">// Set the timer's initial and periodic intervals both</font>
<font color="#0000ff">// to "seconds" seconds and "microseconds" microseconds.</font>
<font color="#2e8b57"><b>void</b></font> setIntervals(<font color="#2e8b57"><b>const</b></font> timeval *tv);
<font color="#0000ff">// Set the timer's initial and periodic intervals both</font>
<font color="#0000ff">// to seconds and microseconds specified in "tv".</font>
<font color="#2e8b57"><b>void</b></font> setIntervals(<font color="#2e8b57"><b>const</b></font> itimerval *itv);
<font color="#0000ff">// Set the timer's initial and periodic intervals as</font>
<font color="#0000ff">// specified by "itv".</font>
<font color="#2e8b57"><b>void</b></font> getInitialInterval(<font color="#2e8b57"><b>long</b></font> *seconds,
<font color="#2e8b57"><b>long</b></font> *microseconds) <font color="#2e8b57"><b>const</b></font>;
<font color="#0000ff">// Set "seconds" and "microseconds" to the timer's</font>
<font color="#0000ff">// initial interval values.</font>
<font color="#2e8b57"><b>void</b></font> getInitialInterval(timeval *tv) <font color="#2e8b57"><b>const</b></font>;
<font color="#0000ff">// Set "tv" to the timer's initial interval values.</font>
<font color="#2e8b57"><b>void</b></font> getPeriodicInterval(<font color="#2e8b57"><b>long</b></font> *seconds,
<font color="#2e8b57"><b>long</b></font> *microseconds) <font color="#2e8b57"><b>const</b></font>;
<font color="#0000ff">// Set "seconds" and "microseconds" to the timer's</font>
<font color="#0000ff">// periodic interval values.</font>
<font color="#2e8b57"><b>void</b></font> getPeriodicInterval(timeval *tv) <font color="#2e8b57"><b>const</b></font>;
<font color="#0000ff">// Set "tv" to the timer's periodic interval values.</font>
<font color="#2e8b57"><b>void</b></font> getIntervals(itimerval *itv) <font color="#2e8b57"><b>const</b></font>;
<font color="#0000ff">// Set "itv" to the timer's intial and periodic values.</font>
<font color="#2e8b57"><b>bool</b></font> start() <font color="#2e8b57"><b>const</b></font>;
<font color="#0000ff">// Start (or restart) the timer. It will first run for</font>
<font color="#0000ff">// the initial interval, then raise a signal, then run</font>
<font color="#0000ff">// over and over for the periodic interval, raising the</font>
<font color="#0000ff">// signal at the end of each interval.</font>
<font color="#2e8b57"><b>bool</b></font> start(itimerval *itv) <font color="#2e8b57"><b>const</b></font>;
<font color="#0000ff">// Start (or restart) the timer. It will first run for</font>
<font color="#0000ff">// the initial interval, then raise a signal, then run</font>
<font color="#0000ff">// over and over for the periodic interval, raising the</font>
<font color="#0000ff">// signal at the end of each interval. "itv" will be</font>
<font color="#0000ff">// set to the intervals that the timer was using prior</font>
<font color="#0000ff">// to calling start().</font>
<font color="#2e8b57"><b>bool</b></font> getTimeRemaining(<font color="#2e8b57"><b>long</b></font> *seconds,
<font color="#2e8b57"><b>long</b></font> *microseconds) <font color="#2e8b57"><b>const</b></font>;
<font color="#0000ff">// Sets "seconds" and "microseconds" to the time</font>
<font color="#0000ff">// remaining before the timer will raise the signal.</font>
<font color="#2e8b57"><b>bool</b></font> getTimeRemaining(timeval *tv) <font color="#2e8b57"><b>const</b></font>;
<font color="#0000ff">// Sets "tv" to the time remaining before the timer</font>
<font color="#0000ff">// will raise the signal.</font>
<font color="#2e8b57"><b>bool</b></font> stop() <font color="#2e8b57"><b>const</b></font>;
<font color="#0000ff">// Stops the currently running timer, but preserves</font>
<font color="#0000ff">// it's initial and perodic intervals.</font>
<font color="#a020f0"> #include </font><font color="#ff00ff"><rudiments/private/intervaltimer.h></font>
};
<font color="#a020f0">#ifdef RUDIMENTS_NAMESPACE</font>
}
<font color="#a020f0">#endif</font>
<font color="#a020f0">#endif</font>
</pre>
</body>
</html>
|