Line 0
Link Here
|
|
|
1 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
2 |
<html> |
3 |
<head> |
4 |
<link rel="stylesheet" href="style.css" type="text/css"> |
5 |
<meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type"> |
6 |
<link rel="Start" href="index.html"> |
7 |
<link rel="Up" href="index.html"> |
8 |
<link title="Index of types" rel=Appendix href="index_types.html"> |
9 |
<link title="Index of values" rel=Appendix href="index_values.html"> |
10 |
<link title="Index of modules" rel=Appendix href="index_modules.html"> |
11 |
<link title="Liboevent" rel="Chapter" href="Liboevent.html"><link title="Basic Libevent Operations" rel="Section" href="#5_BasicLibeventOperations"> |
12 |
<link title="Process Events" rel="Section" href="#5_ProcessEvents"> |
13 |
<title>Liboevent</title> |
14 |
</head> |
15 |
<body> |
16 |
<div class="navbar"> <a href="index.html">Up</a> |
17 |
</div> |
18 |
<center><h1>Module <a href="type_Liboevent.html">Liboevent</a></h1></center> |
19 |
<br> |
20 |
<pre><span class="keyword">module</span> Liboevent: <code class="code">sig</code> <a href="Liboevent.html">..</a> <code class="code">end</code></pre>The Ocaml Event library provides an interface to the event API. |
21 |
<p> |
22 |
|
23 |
The event API provides a mechanism to execute a function when a |
24 |
specific event on a file descriptor occurs or after a given time |
25 |
has passed. |
26 |
<p> |
27 |
|
28 |
This library is a wrapper of the libevent API made by Nils |
29 |
Provos. For more information about this library see: |
30 |
http://www.monkey.org/~provos/libevent. |
31 |
<p> |
32 |
|
33 |
Currently, libevent supports kqueue(2), select(2), poll(2) and |
34 |
epoll(4). Support for /dev/poll is planned.<br> |
35 |
<b>Author(s):</b> Maas-Maarten Zeeman<br> |
36 |
<hr width="100%"> |
37 |
<pre><span class="keyword">type</span> <a name="TYPEevent"></a><code class="type"></code>event </pre> |
38 |
<div class="info"> |
39 |
The type of events<br> |
40 |
</div> |
41 |
|
42 |
<br><code><span class="keyword">type</span> <a name="TYPEevent_flags"></a><code class="type"></code>event_flags = </code><table class="typetable"> |
43 |
<tr> |
44 |
<td align="left" valign="top" > |
45 |
<code><span class="keyword">|</span></code></td> |
46 |
<td align="left" valign="top" > |
47 |
<code><span class="constructor">TIMEOUT</span></code></td> |
48 |
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >A timeout occurred.</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td> |
49 |
</tr> |
50 |
<tr> |
51 |
<td align="left" valign="top" > |
52 |
<code><span class="keyword">|</span></code></td> |
53 |
<td align="left" valign="top" > |
54 |
<code><span class="constructor">READ</span></code></td> |
55 |
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >A read is possible.</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td> |
56 |
</tr> |
57 |
<tr> |
58 |
<td align="left" valign="top" > |
59 |
<code><span class="keyword">|</span></code></td> |
60 |
<td align="left" valign="top" > |
61 |
<code><span class="constructor">WRITE</span></code></td> |
62 |
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >A write operation is possible.</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td> |
63 |
</tr> |
64 |
<tr> |
65 |
<td align="left" valign="top" > |
66 |
<code><span class="keyword">|</span></code></td> |
67 |
<td align="left" valign="top" > |
68 |
<code><span class="constructor">SIGNAL</span></code></td> |
69 |
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >A signal occurred.</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td> |
70 |
</tr></table> |
71 |
|
72 |
<div class="info"> |
73 |
The possible event types<br> |
74 |
</div> |
75 |
|
76 |
<pre><span class="keyword">type</span> <a name="TYPEevent_callback"></a><code class="type"></code>event_callback = <code class="type">Unix.file_descr -> <a href="Liboevent.html#TYPEevent_flags">event_flags</a> -> unit</code> </pre> |
77 |
<div class="info"> |
78 |
The type of event callbacks<br> |
79 |
</div> |
80 |
|
81 |
<br> |
82 |
<a name="5_BasicLibeventOperations"></a> |
83 |
<h5>Basic Libevent Operations</h5><br> |
84 |
<pre><span class="keyword">val</span> <a name="VALcreate"></a>create : <code class="type">unit -> <a href="Liboevent.html#TYPEevent">event</a></code></pre><div class="info"> |
85 |
Create a new empty event<br> |
86 |
</div> |
87 |
<pre><span class="keyword">val</span> <a name="VALfd"></a>fd : <code class="type"><a href="Liboevent.html#TYPEevent">event</a> -> Unix.file_descr</code></pre><div class="info"> |
88 |
<code class="code">fd event</code> returns the file descriptor associated with the event<br> |
89 |
</div> |
90 |
<pre><span class="keyword">val</span> <a name="VALsignal"></a>signal : <code class="type"><a href="Liboevent.html#TYPEevent">event</a> -> int</code></pre><div class="info"> |
91 |
<code class="code">signal event</code> returns the signal associated with the event<br> |
92 |
</div> |
93 |
<pre><span class="keyword">val</span> <a name="VALset"></a>set : <code class="type"><a href="Liboevent.html#TYPEevent">event</a> -><br> Unix.file_descr -><br> <a href="Liboevent.html#TYPEevent_flags">event_flags</a> list -><br> persist:bool -> <a href="Liboevent.html#TYPEevent_callback">event_callback</a> -> unit</code></pre><div class="info"> |
94 |
<code class="code">set event fd type persist callback</code> initializes the event. The |
95 |
flag <code class="code">persist</code> makes an event persitent until <code class="code">Libevent.del</code> is |
96 |
called.<br> |
97 |
</div> |
98 |
<pre><span class="keyword">val</span> <a name="VALset_signal"></a>set_signal : <code class="type"><a href="Liboevent.html#TYPEevent">event</a> -><br> signal:int -> persist:bool -> <a href="Liboevent.html#TYPEevent_callback">event_callback</a> -> unit</code></pre><div class="info"> |
99 |
<code class="code">set_signal event signal persist callback</code> initializes the event. The |
100 |
flag <code class="code">persist</code> makes an event persistent unit <code class="code">Libevent.del</code> is |
101 |
called.<br> |
102 |
</div> |
103 |
<pre><span class="keyword">val</span> <a name="VALadd"></a>add : <code class="type"><a href="Liboevent.html#TYPEevent">event</a> -> float option -> unit</code></pre><div class="info"> |
104 |
<code class="code">add event timeout</code> adds the <code class="code">event</code> and schedules the execution |
105 |
of the function specified with <code class="code">Libevent.set</code>, or in at least the |
106 |
time specified in the <code class="code">timeout</code>. If <code class="code">timeout</code> is <code class="code">None</code>, no |
107 |
timeout occures, and the function will only be called if a |
108 |
matching event occurs on the file descriptor.<br> |
109 |
</div> |
110 |
<pre><span class="keyword">val</span> <a name="VALdel"></a>del : <code class="type"><a href="Liboevent.html#TYPEevent">event</a> -> unit</code></pre><div class="info"> |
111 |
Del the event<br> |
112 |
</div> |
113 |
<pre><span class="keyword">val</span> <a name="VALpending"></a>pending : <code class="type"><a href="Liboevent.html#TYPEevent">event</a> -> <a href="Liboevent.html#TYPEevent_flags">event_flags</a> list -> bool</code></pre><br> |
114 |
<a name="5_ProcessEvents"></a> |
115 |
<h5>Process Events</h5><br> |
116 |
<pre><span class="keyword">val</span> <a name="VALdispatch"></a>dispatch : <code class="type">unit -> unit</code></pre><div class="info"> |
117 |
In order to process events, an application needs to call dispatch. This |
118 |
* function only returns on error, and should replace the event core of the |
119 |
* application<br> |
120 |
</div> |
121 |
<br><code><span class="keyword">type</span> <a name="TYPEloop_flags"></a><code class="type"></code>loop_flags = </code><table class="typetable"> |
122 |
<tr> |
123 |
<td align="left" valign="top" > |
124 |
<code><span class="keyword">|</span></code></td> |
125 |
<td align="left" valign="top" > |
126 |
<code><span class="constructor">ONCE</span></code></td> |
127 |
|
128 |
</tr> |
129 |
<tr> |
130 |
<td align="left" valign="top" > |
131 |
<code><span class="keyword">|</span></code></td> |
132 |
<td align="left" valign="top" > |
133 |
<code><span class="constructor">NONBLOCK</span></code></td> |
134 |
|
135 |
</tr></table> |
136 |
|
137 |
|
138 |
<pre><span class="keyword">val</span> <a name="VALloop"></a>loop : <code class="type"><a href="Liboevent.html#TYPEloop_flags">loop_flags</a> -> unit</code></pre><div class="info"> |
139 |
Provides an interface for single pass execution of pending events<br> |
140 |
</div> |
141 |
</body></html> |