<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <link rel="stylesheet" href="style.css" type="text/css"> <meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type"> <link rel="Start" href="index.html"> <link rel="previous" href="Lwt_sys.html"> <link rel="next" href="Lwt_bytes.html"> <link rel="Up" href="index.html"> <link title="Index of types" rel=Appendix href="index_types.html"> <link title="Index of exceptions" rel=Appendix href="index_exceptions.html"> <link title="Index of values" rel=Appendix href="index_values.html"> <link title="Index of class attributes" rel=Appendix href="index_attributes.html"> <link title="Index of class methods" rel=Appendix href="index_methods.html"> <link title="Index of classes" rel=Appendix href="index_classes.html"> <link title="Index of class types" rel=Appendix href="index_class_types.html"> <link title="Index of modules" rel=Appendix href="index_modules.html"> <link title="Index of module types" rel=Appendix href="index_module_types.html"> <link title="Lwt_condition" rel="Chapter" href="Lwt_condition.html"> <link title="Lwt_list" rel="Chapter" href="Lwt_list.html"> <link title="Lwt" rel="Chapter" href="Lwt.html"> <link title="Lwt_mutex" rel="Chapter" href="Lwt_mutex.html"> <link title="Lwt_mvar" rel="Chapter" href="Lwt_mvar.html"> <link title="Lwt_pool" rel="Chapter" href="Lwt_pool.html"> <link title="Lwt_sequence" rel="Chapter" href="Lwt_sequence.html"> <link title="Lwt_stream" rel="Chapter" href="Lwt_stream.html"> <link title="Lwt_switch" rel="Chapter" href="Lwt_switch.html"> <link title="Lwt_util" rel="Chapter" href="Lwt_util.html"> <link title="Lwt_pqueue" rel="Chapter" href="Lwt_pqueue.html"> <link title="Lwt_lib" rel="Chapter" href="Lwt_lib.html"> <link title="Lwt_glib" rel="Chapter" href="Lwt_glib.html"> <link title="Lwt_preemptive" rel="Chapter" href="Lwt_preemptive.html"> <link title="Lwt_event" rel="Chapter" href="Lwt_event.html"> <link title="Lwt_signal" rel="Chapter" href="Lwt_signal.html"> <link title="Lwt_react" rel="Chapter" href="Lwt_react.html"> <link title="Lwt_ssl" rel="Chapter" href="Lwt_ssl.html"> <link title="Lwt_text" rel="Chapter" href="Lwt_text.html"> <link title="Lwt_term" rel="Chapter" href="Lwt_term.html"> <link title="Lwt_read_line" rel="Chapter" href="Lwt_read_line.html"> <link title="Lwt_top" rel="Chapter" href="Lwt_top.html"> <link title="Lwt_chan" rel="Chapter" href="Lwt_chan.html"> <link title="Lwt_daemon" rel="Chapter" href="Lwt_daemon.html"> <link title="Lwt_gc" rel="Chapter" href="Lwt_gc.html"> <link title="Lwt_io" rel="Chapter" href="Lwt_io.html"> <link title="Lwt_log" rel="Chapter" href="Lwt_log.html"> <link title="Lwt_main" rel="Chapter" href="Lwt_main.html"> <link title="Lwt_process" rel="Chapter" href="Lwt_process.html"> <link title="Lwt_throttle" rel="Chapter" href="Lwt_throttle.html"> <link title="Lwt_timeout" rel="Chapter" href="Lwt_timeout.html"> <link title="Lwt_unix" rel="Chapter" href="Lwt_unix.html"> <link title="Lwt_sys" rel="Chapter" href="Lwt_sys.html"> <link title="Lwt_engine" rel="Chapter" href="Lwt_engine.html"> <link title="Lwt_bytes" rel="Chapter" href="Lwt_bytes.html"> <link title="Pa_lwt" rel="Chapter" href="Pa_lwt.html"> <link title="Pa_lwt_log" rel="Chapter" href="Pa_lwt_log.html"><link title="Events" rel="Section" href="#6_Events"> <link title="Event loop functions" rel="Section" href="#6_Eventloopfunctions"> <link title="Engines" rel="Section" href="#6_Engines"> <link title="Predefined engines" rel="Section" href="#6_Predefinedengines"> <link title="The current engine" rel="Section" href="#6_Thecurrentengine"> <title>Lwt_engine</title> </head> <body> <div class="navbar"><a class="pre" href="Lwt_sys.html" title="Lwt_sys">Previous</a> <a class="up" href="index.html" title="Index">Up</a> <a class="post" href="Lwt_bytes.html" title="Lwt_bytes">Next</a> </div> <h1>Module <a href="type_Lwt_engine.html">Lwt_engine</a></h1> <pre><span class="keyword">module</span> Lwt_engine: <code class="code"><span class="keyword">sig</span></code> <a href="Lwt_engine.html">..</a> <code class="code"><span class="keyword">end</span></code></pre><div class="info"> Lwt unix main loop engine<br> </div> <hr width="100%"> <br> <h6 id="6_Events">Events</h6><br> <pre><span id="TYPEevent"><span class="keyword">type</span> <code class="type"></code>event</span> </pre> <div class="info"> Type of events. An event represent a callback registered to be called when some event occurs.<br> </div> <pre><span id="VALstop_event"><span class="keyword">val</span> stop_event</span> : <code class="type"><a href="Lwt_engine.html#TYPEevent">event</a> -> unit</code></pre><div class="info"> <code class="code">stop_event event</code> stops the given event.<br> </div> <pre><span id="VALfake_event"><span class="keyword">val</span> fake_event</span> : <code class="type"><a href="Lwt_engine.html#TYPEevent">event</a></code></pre><div class="info"> Event which does nothing when stopped.<br> </div> <br> <h6 id="6_Eventloopfunctions">Event loop functions</h6><br> <pre><span id="VALiter"><span class="keyword">val</span> iter</span> : <code class="type">bool -> unit</code></pre><div class="info"> <code class="code">iter block</code> performs one iteration of the main loop. If <code class="code">block</code> is <code class="code"><span class="keyword">true</span></code> the function must blocks until one event become available, otherwise it should just check for available events and return immediatly.<br> </div> <pre><span id="VALon_readable"><span class="keyword">val</span> on_readable</span> : <code class="type">Unix.file_descr -> (<a href="Lwt_engine.html#TYPEevent">event</a> -> unit) -> <a href="Lwt_engine.html#TYPEevent">event</a></code></pre><div class="info"> <code class="code">on_readable fd f</code> calls <code class="code">f</code> each time <code class="code">fd</code> becomes readable.<br> </div> <pre><span id="VALon_writable"><span class="keyword">val</span> on_writable</span> : <code class="type">Unix.file_descr -> (<a href="Lwt_engine.html#TYPEevent">event</a> -> unit) -> <a href="Lwt_engine.html#TYPEevent">event</a></code></pre><div class="info"> <code class="code">on_readable fd f</code> calls <code class="code">f</code> each time <code class="code">fd</code> becomes writable.<br> </div> <pre><span id="VALon_timer"><span class="keyword">val</span> on_timer</span> : <code class="type">float -> bool -> (<a href="Lwt_engine.html#TYPEevent">event</a> -> unit) -> <a href="Lwt_engine.html#TYPEevent">event</a></code></pre><div class="info"> <code class="code">on_timer delay repeat f</code> calls <code class="code">f</code> one time after <code class="code">delay</code> seconds. If <code class="code">repeat</code> is <code class="code"><span class="keyword">true</span></code> then <code class="code">f</code> is called each <code class="code">delay</code> seconds, otherwise it is called only one time.<br> </div> <pre><span id="VALreadable_count"><span class="keyword">val</span> readable_count</span> : <code class="type">unit -> int</code></pre><div class="info"> Returns the number of events waiting for a file descriptor to become readable.<br> </div> <pre><span id="VALwritable_count"><span class="keyword">val</span> writable_count</span> : <code class="type">unit -> int</code></pre><div class="info"> Returns the number of events waiting for a file descriptor to become writable.<br> </div> <pre><span id="VALtimer_count"><span class="keyword">val</span> timer_count</span> : <code class="type">unit -> int</code></pre><div class="info"> Returns the number of registered timers.<br> </div> <pre><span id="VALfake_io"><span class="keyword">val</span> fake_io</span> : <code class="type">Unix.file_descr -> unit</code></pre><div class="info"> Simulates activity on the given file descriptor.<br> </div> <br> <h6 id="6_Engines">Engines</h6><br> <br> An engine represent a set of functions used to register different kind of callbacks for different kind of events.<br> <pre><span name="TYPEabstract"><span class="keyword">class</span> <span class="keyword">virtual</span> <a href="Lwt_engine.abstract-c.html">abstract</a></span> : <code class="type"></code><code class="code"><span class="keyword">object</span></code> <a href="Lwt_engine.abstract-c.html">..</a> <code class="code"><span class="keyword">end</span></code></pre><div class="info"> Abstract class for engines. </div> <pre><span id="TYPEt"><span class="keyword">class type</span> <a href="Lwt_engine.t-c.html">t</a></span> = <code class="code"><span class="keyword">object</span></code> <a href="Lwt_engine.t-c.html">..</a> <code class="code"><span class="keyword">end</span></code></pre><div class="info"> Type of engines. </div> <br> <h6 id="6_Predefinedengines">Predefined engines</h6><br> <pre><span id="TYPEev_loop"><span class="keyword">type</span> <code class="type"></code>ev_loop</span> </pre> <div class="info"> Type of libev loops.<br> </div> <pre><span name="TYPElibev"><span class="keyword">class</span> <a href="Lwt_engine.libev-c.html">libev</a></span> : <code class="type"></code><code class="code"><span class="keyword">object</span></code> <a href="Lwt_engine.libev-c.html">..</a> <code class="code"><span class="keyword">end</span></code></pre><div class="info"> Engine based on libev. </div> <pre><span name="TYPEselect"><span class="keyword">class</span> <a href="Lwt_engine.select-c.html">select</a></span> : <code class="type"></code><code class="type"><a href="Lwt_engine.t-c.html">t</a></code></pre><div class="info"> Engine based on <code class="code"><span class="constructor">Unix</span>.select</code>. </div> <pre><span name="TYPEselect_based"><span class="keyword">class</span> <span class="keyword">virtual</span> <a href="Lwt_engine.select_based-c.html">select_based</a></span> : <code class="type"></code><code class="code"><span class="keyword">object</span></code> <a href="Lwt_engine.select_based-c.html">..</a> <code class="code"><span class="keyword">end</span></code></pre><div class="info"> Abstract class for engines based on a select-like function. </div> <pre><span name="TYPEpoll_based"><span class="keyword">class</span> <span class="keyword">virtual</span> <a href="Lwt_engine.poll_based-c.html">poll_based</a></span> : <code class="type"></code><code class="code"><span class="keyword">object</span></code> <a href="Lwt_engine.poll_based-c.html">..</a> <code class="code"><span class="keyword">end</span></code></pre><div class="info"> Abstract class for engines based on a poll-like function. </div> <br> <h6 id="6_Thecurrentengine">The current engine</h6><br> <pre><span id="VALget"><span class="keyword">val</span> get</span> : <code class="type">unit -> <a href="Lwt_engine.t-c.html">t</a></code></pre><div class="info"> <code class="code">get ()</code> returns the engine currently in use.<br> </div> <pre><span id="VALset"><span class="keyword">val</span> set</span> : <code class="type">?transfer:bool -> ?destroy:bool -> #<a href="Lwt_engine.t-c.html">t</a> -> unit</code></pre><div class="info"> <code class="code">set ?transfer ?destroy engine</code> replaces the current engine by the given one. <p> If <code class="code">transfer</code> is <code class="code"><span class="keyword">true</span></code> (the default) all events from the current engine are transferred to the new one. <p> If <code class="code">destroy</code> is <code class="code"><span class="keyword">true</span></code> (the default) then the current engine is destroyed before being replaced.<br> </div> </body></html>