File: snooze.h.html

package info (click to toggle)
rudiments 0.31-2
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 7,516 kB
  • ctags: 3,248
  • sloc: asm: 23,776; cpp: 22,792; sh: 7,769; ansic: 1,769; makefile: 1,054; xml: 169; perl: 19
file content (105 lines) | stat: -rw-r--r-- 8,534 bytes parent folder | download | duplicates (2)
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
<html>
<head>
<title>~/src/firstworks/rudiments-0.31/include/rudiments/snooze.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_SNOOZE_H</font>
<font color="#a020f0">#define RUDIMENTS_SNOOZE_H</font>

<font color="#a020f0">#include </font><font color="#ff00ff">&lt;rudiments/private/snoozeincludes.h&gt;</font>

<font color="#0000ff">// The snooze class provides methods for suspending process execution.</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> snooze {
        <font color="#a52a2a"><b>public</b></font>:

                <font color="#0000ff">// These methods allow you to suspend execution of the process</font>
                <font color="#0000ff">// for a specified amount of time.  They return true on success</font>
                <font color="#0000ff">// and false on failure (such as if a signal interrupts them).</font>
                <font color="#2e8b57"><b>static</b></font> <font color="#2e8b57"><b>bool</b></font>   macrosnooze(<font color="#2e8b57"><b>long</b></font> seconds);
                                <font color="#0000ff">// Suspend execution for &quot;seconds&quot; seconds.</font>
                <font color="#2e8b57"><b>static</b></font> <font color="#2e8b57"><b>bool</b></font>   macrosnooze(<font color="#2e8b57"><b>long</b></font> seconds,
                                        <font color="#2e8b57"><b>long</b></font> *remainingseconds);
                                <font color="#0000ff">// Suspend execution for &quot;seconds&quot; seconds.</font>
                                <font color="#0000ff">// If a signal interrupts the snooze,</font>
                                <font color="#0000ff">// &quot;remainingseconds&quot; is populated with the</font>
                                <font color="#0000ff">// number of seconds that were not slept.</font>


                <font color="#2e8b57"><b>static</b></font> <font color="#2e8b57"><b>bool</b></font>   microsnooze(<font color="#2e8b57"><b>long</b></font> seconds,
                                        <font color="#2e8b57"><b>long</b></font> microseconds);
                                <font color="#0000ff">// Suspend execution for &quot;seconds&quot; seconds</font>
                                <font color="#0000ff">// and &quot;microseconds&quot; microseconds.</font>
                <font color="#2e8b57"><b>static</b></font> <font color="#2e8b57"><b>bool</b></font>   microsnooze(<font color="#2e8b57"><b>long</b></font> seconds,
                                        <font color="#2e8b57"><b>long</b></font> microseconds,
                                        <font color="#2e8b57"><b>long</b></font> *secondsremaining,
                                        <font color="#2e8b57"><b>long</b></font> *microsecondsremaining);
                                <font color="#0000ff">// Suspend execution for &quot;seconds&quot; seconds</font>
                                <font color="#0000ff">// and &quot;microseconds&quot; microseconds.</font>
                                <font color="#0000ff">// If a signal interrupts the snooze,</font>
                                <font color="#0000ff">// &quot;remainingseconds&quot; is populated with the</font>
                                <font color="#0000ff">// number of seconds that were not slept and</font>
                                <font color="#0000ff">// &quot;remainingmicroseconds&quot; is populated with the</font>
                                <font color="#0000ff">// number of microseconds that were not slept.</font>
                <font color="#2e8b57"><b>static</b></font> <font color="#2e8b57"><b>bool</b></font>   microsnooze(timeval *timetosnooze);
                                <font color="#0000ff">// Suspend execution for the number of seconds</font>
                                <font color="#0000ff">// and microseconds specified in &quot;timetosnooze&quot;.</font>
                <font color="#2e8b57"><b>static</b></font> <font color="#2e8b57"><b>bool</b></font>   microsnooze(timeval *timetosnooze,
                                                timeval *timeremaining);
                                <font color="#0000ff">// Suspend execution for the number of seconds</font>
                                <font color="#0000ff">// and microseconds specified in &quot;timetosnooze&quot;.</font>
                                <font color="#0000ff">// If a signal interrupts the snooze,</font>
                                <font color="#0000ff">// &quot;timeremaining&quot; is populated with the number</font>
                                <font color="#0000ff">// of seconds and microseconds that were not</font>
                                <font color="#0000ff">// slept.</font>


                <font color="#0000ff">// These methods allow you to snooze for very small amounts</font>
                <font color="#0000ff">// of time.  Note that some systems do not have true</font>
                <font color="#0000ff">// nanosecond clock resolution.</font>
                <font color="#2e8b57"><b>static</b></font> <font color="#2e8b57"><b>bool</b></font>   nanosnooze(<font color="#2e8b57"><b>long</b></font> seconds,
                                        <font color="#2e8b57"><b>long</b></font> nanoseconds);
                                <font color="#0000ff">// Suspend execution for &quot;seconds&quot; seconds</font>
                                <font color="#0000ff">// and &quot;nanoseconds&quot; nanoseconds.</font>
                <font color="#2e8b57"><b>static</b></font> <font color="#2e8b57"><b>bool</b></font>   nanosnooze(<font color="#2e8b57"><b>long</b></font> seconds,
                                        <font color="#2e8b57"><b>long</b></font> nanoseconds,
                                        <font color="#2e8b57"><b>long</b></font> *secondsremaining,
                                        <font color="#2e8b57"><b>long</b></font> *nanosecondsremaining);
                                <font color="#0000ff">// Suspend execution for &quot;seconds&quot; seconds</font>
                                <font color="#0000ff">// and &quot;nanoseconds&quot; nanoseconds.</font>
                                <font color="#0000ff">// If a signal interrupts the snooze,</font>
                                <font color="#0000ff">// &quot;remainingseconds&quot; is populated with the</font>
                                <font color="#0000ff">// number of seconds that were not slept and</font>
                                <font color="#0000ff">// &quot;remainingnanoseconds&quot; is populated with the</font>
                                <font color="#0000ff">// number of nanoseconds that were not slept.</font>
                <font color="#2e8b57"><b>static</b></font> <font color="#2e8b57"><b>bool</b></font>   nanosnooze(timespec *timetosnooze);
                                <font color="#0000ff">// Suspend execution for the number of seconds</font>
                                <font color="#0000ff">// and nanoseconds specified in &quot;timetosnooze&quot;.</font>
                <font color="#2e8b57"><b>static</b></font> <font color="#2e8b57"><b>bool</b></font>   nanosnooze(timespec *timetosnooze,
                                                timespec *timeremaining);
                                <font color="#0000ff">// Suspend execution for the number of seconds</font>
                                <font color="#0000ff">// and nanoseconds specified in &quot;timetosnooze&quot;.</font>
                                <font color="#0000ff">// If a signal interrupts the snooze,</font>
                                <font color="#0000ff">// &quot;timeremaining&quot; is populated with the number</font>
                                <font color="#0000ff">// of seconds and nanoseconds that were not</font>
                                <font color="#0000ff">// slept.</font>
};

<font color="#a020f0">#ifdef RUDIMENTS_NAMESPACE</font>
}
<font color="#a020f0">#endif</font>

<font color="#a020f0">#endif</font>
</pre>
</body>
</html>