File: listener.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 (108 lines) | stat: -rw-r--r-- 7,396 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
106
107
108
<html>
<head>
<title>~/src/firstworks/rudiments-0.31/include/rudiments/listener.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) 2002 David Muse</font>
<font color="#0000ff">// See the COPYING file for more information.</font>

<font color="#a020f0">#ifndef RUDIMENTS_LISTENER_H</font>
<font color="#a020f0">#define RUDIMENTS_LISTENER_H</font>

<font color="#a020f0">#include </font><font color="#ff00ff">&lt;rudiments/private/listenerincludes.h&gt;</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>typedef</b></font> linkedlist&lt;filedescriptor *&gt;            listenerlist;
<font color="#2e8b57"><b>typedef</b></font> linkedlistnode&lt;filedescriptor *&gt;        listenerlistnode;

<font color="#0000ff">// The listener class listens on a pool of file descriptors.</font>

<font color="#2e8b57"><b>class</b></font> listenerprivate;

<font color="#2e8b57"><b>class</b></font> listener {
        <font color="#a52a2a"><b>public</b></font>:
                        listener();
                <font color="#2e8b57"><b>virtual</b></font>       ~listener();

                <font color="#2e8b57"><b>void</b></font>  addFileDescriptor(filedescriptor *fd);
                                <font color="#0000ff">// Adds the specified file descriptor to</font>
                                <font color="#0000ff">// the pool that the listener is listening on.</font>

                <font color="#2e8b57"><b>int</b></font>   waitForNonBlockingRead(<font color="#2e8b57"><b>long</b></font> sec, <font color="#2e8b57"><b>long</b></font> usec);
                                <font color="#0000ff">// Causes the application to wait until a read()</font>
                                <font color="#0000ff">// will proceed without blocking or until &quot;sec&quot;</font>
                                <font color="#0000ff">// seconds and &quot;usec&quot; microseconds have elapsed.</font>
                                <font color="#0000ff">//</font>
                                <font color="#0000ff">// Entering -1 for either parameter causes the</font>
                                <font color="#0000ff">// method to wait indefinitely.  </font>
                                <font color="#0000ff">//</font>
                                <font color="#0000ff">// Entering 0 for both parameters causes the</font>
                                <font color="#0000ff">// method to fall through immediately, returning</font>
                                <font color="#0000ff">// RESULT_TIMEOUT unless a read() will</font>
                                <font color="#0000ff">// immediately proceed without blocking.</font>
                                <font color="#0000ff">//</font>
                                <font color="#0000ff">// Returns RESULT_ERROR on error, RESULT_TIMEOUT</font>
                                <font color="#0000ff">// on timeout and otherwise returns the number</font>
                                <font color="#0000ff">// of file descriptors that are ready to be</font>
                                <font color="#0000ff">// read from.</font>
                <font color="#2e8b57"><b>int</b></font>   waitForNonBlockingWrite(<font color="#2e8b57"><b>long</b></font> sec, <font color="#2e8b57"><b>long</b></font> usec);
                                <font color="#0000ff">// Causes the application to wait until a</font>
                                <font color="#0000ff">// write() will proceed without blocking or</font>
                                <font color="#0000ff">// until &quot;sec&quot; seconds and &quot;usec&quot; microseconds</font>
                                <font color="#0000ff">// have elapsed.</font>
                                <font color="#0000ff">//</font>
                                <font color="#0000ff">// Entering -1 for either parameter causes the</font>
                                <font color="#0000ff">// method to wait indefinitely.  </font>
                                <font color="#0000ff">//</font>
                                <font color="#0000ff">// Entering 0 for both parameters causes the</font>
                                <font color="#0000ff">// method to fall through immediately, returning</font>
                                <font color="#0000ff">// RESULT_TIMEOUT unless a write() will</font>
                                <font color="#0000ff">// immediately proceed without blocking.</font>
                                <font color="#0000ff">//</font>
                                <font color="#0000ff">// Returns RESULT_ERROR on error, RESULT_TIMEOUT</font>
                                <font color="#0000ff">// on timeout and otherwise returns the number</font>
                                <font color="#0000ff">// of file descriptors that are ready to be </font>
                                <font color="#0000ff">// written to.</font>

                listenerlist    *getReadyList();
                                <font color="#0000ff">// Returns the list of file descriptors that</font>
                                <font color="#0000ff">// were ready for read after the last call to</font>
                                <font color="#0000ff">// waitForNonBlockingRead() or ready for</font>
                                <font color="#0000ff">// write after the last call to</font>
                                <font color="#0000ff">// waitForNonBlockingWrite().</font>

                <font color="#2e8b57"><b>void</b></font>  removeFileDescriptor(filedescriptor *fd);
                                <font color="#0000ff">// Removes the specified file descriptor from</font>
                                <font color="#0000ff">// the pool.</font>

                <font color="#2e8b57"><b>void</b></font>  removeAllFileDescriptors();
                                <font color="#0000ff">// Removes all file descriptors from the pool.</font>


                <font color="#0000ff">// By default, if a wait is occurring and a signal interrupts</font>
                <font color="#0000ff">// it, the read or write returns with errno set to EINTR and</font>
                <font color="#0000ff">// must be retried.  These methods override that behavior.</font>
                <font color="#2e8b57"><b>void</b></font>  retryInterruptedWaits();
                        <font color="#0000ff">// Causes waits to automatically retry if</font>
                        <font color="#0000ff">// interrupted by a signal.  This is the default.</font>
                <font color="#2e8b57"><b>void</b></font>  dontRetryInterruptedWaits();
                        <font color="#0000ff">// Causes waits not to automatically retry if</font>
                        <font color="#0000ff">// interrupted by a signal.  This is the default.</font>

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

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

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