Sophie

Sophie

distrib > Mageia > 3 > i586 > by-pkgid > 201a9f979540fcfb8136ebdbfe063650 > files > 17

ocaml-lwt-doc-2.4.2-5.mga3.i586.rpm

<!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_lib.html">
<link rel="next" href="Lwt_preemptive.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"><title>Lwt_glib</title>
</head>
<body>
<div class="navbar"><a class="pre" href="Lwt_lib.html" title="Lwt_lib">Previous</a>
&nbsp;<a class="up" href="index.html" title="Index">Up</a>
&nbsp;<a class="post" href="Lwt_preemptive.html" title="Lwt_preemptive">Next</a>
</div>
<h1>Module <a href="type_Lwt_glib.html">Lwt_glib</a></h1>
<pre><span class="keyword">module</span> Lwt_glib: <code class="code"><span class="keyword">sig</span></code> <a href="Lwt_glib.html">..</a> <code class="code"><span class="keyword">end</span></code></pre><div class="info">
Glib integration<br>
</div>
<hr width="100%">
<br>
This module allow to use Lwt in GTK applications.
<p>

    Here is what you have to do to make Lwt and GTK work together:<ul>
<li>call <a href="Lwt_glib.html#VALinstall"><code class="code"><span class="constructor">Lwt_glib</span>.install</code></a> at the beginning of your program (before or
    after GMain.init, it does not matter)</li>
<li>do not call GMain.main, write your application as a normal Lwt
    application instead.</li>
</ul>

    For example:
<p>

    <pre class="codepre"><code class="code">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">let</span>&nbsp;()&nbsp;=&nbsp;<span class="constructor">Lwt_main</span>.run&nbsp;(<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">(*&nbsp;Initializes&nbsp;GTK.&nbsp;*)</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ignore&nbsp;(<span class="constructor">GMain</span>.init&nbsp;());<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">(*&nbsp;Install&nbsp;Lwt&lt;-&gt;Glib&nbsp;integration.&nbsp;*)</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="constructor">Lwt_glib</span>.install&nbsp;();<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">(*&nbsp;Thread&nbsp;which&nbsp;is&nbsp;wakeup&nbsp;when&nbsp;the&nbsp;main&nbsp;window&nbsp;is&nbsp;closed.&nbsp;*)</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">let</span>&nbsp;waiter,&nbsp;wakener&nbsp;=&nbsp;<span class="constructor">Lwt</span>.wait&nbsp;()&nbsp;<span class="keyword">in</span><br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">(*&nbsp;Create&nbsp;a&nbsp;window.&nbsp;*)</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">let</span>&nbsp;window&nbsp;=&nbsp;<span class="constructor">GWindow</span>.window&nbsp;()&nbsp;<span class="keyword">in</span><br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">(*&nbsp;Display&nbsp;something&nbsp;inside&nbsp;the&nbsp;window.&nbsp;*)</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ignore&nbsp;(<span class="constructor">GMisc</span>.label&nbsp;~text:<span class="string">"Hello,&nbsp;world!"</span>&nbsp;~packing:window<span class="keywordsign">#</span>add&nbsp;());<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">(*&nbsp;Quit&nbsp;when&nbsp;the&nbsp;window&nbsp;is&nbsp;closed.&nbsp;*)</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ignore&nbsp;(window<span class="keywordsign">#</span>connect<span class="keywordsign">#</span>destroy&nbsp;(<span class="constructor">Lwt</span>.wakeup&nbsp;wakener));<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">(*&nbsp;Show&nbsp;the&nbsp;window.&nbsp;*)</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;window<span class="keywordsign">#</span>show&nbsp;();<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">(*&nbsp;Wait&nbsp;for&nbsp;it&nbsp;to&nbsp;be&nbsp;closed.&nbsp;*)</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;waiter<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)<br>
&nbsp;&nbsp;&nbsp;&nbsp;</code></pre><br>
<pre><span id="VALinstall"><span class="keyword">val</span> install</span> : <code class="type">?mode:[ `glib_into_lwt | `lwt_into_glib ] -> unit -> unit</code></pre><div class="info">
Install the Glib&lt;-&gt;Lwt integration.
<p>

      If <code class="code">mode</code> is <code class="code"><span class="keywordsign">`</span>glib_into_lwt</code> then glib will use the Lwt main
      loop, and if <code class="code">mode</code> is <code class="code"><span class="keywordsign">`</span>lwt_into_glib</code> then Lwt will use the
      Glib main loop.
<p>

      <code class="code">mode</code> defaults to <code class="code"><span class="keywordsign">`</span>lwt_into_glib</code> because it is more
      portable. <code class="code"><span class="keywordsign">`</span>glib_into_lwt</code> does not work under Windows and
      MacOS.
<p>

      If the integration is already active, this function does
      nothing.<br>
</div>
<pre><span id="VALremove"><span class="keyword">val</span> remove</span> : <code class="type">unit -> unit</code></pre><div class="info">
Remove the Glib&lt;-&gt;Lwt integration.<br>
</div>
<pre><span id="VALiter"><span class="keyword">val</span> iter</span> : <code class="type">bool -> unit</code></pre><div class="info">
This function is not related to Lwt. <code class="code">iter may_block</code> does the
      same as <code class="code"><span class="constructor">Glib</span>.<span class="constructor">Main</span>.iteration may_block</code> but can safely be called
      in a multi-threaded program, it will not block the whole
      program.
<p>

      For example:
<p>

      <pre class="codepre"><code class="code">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">let</span>&nbsp;main&nbsp;()&nbsp;=<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">while</span>&nbsp;<span class="keyword">true</span>&nbsp;<span class="keyword">do</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="constructor">Lwt_glib</span>.iter&nbsp;<span class="keyword">true</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">done</span><br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">let</span>&nbsp;thread&nbsp;=&nbsp;<span class="constructor">Thread</span>.create&nbsp;main&nbsp;()<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code></pre>
<p>

      Note: you can call this function only from one thread at a time,
      otherwise it will raise <code class="code"><span class="constructor">Failure</span></code>.<br>
</div>
<pre><span id="VALwakeup"><span class="keyword">val</span> wakeup</span> : <code class="type">unit -> unit</code></pre><div class="info">
If one thread is blocking on <a href="Lwt_glib.html#VALiter"><code class="code"><span class="constructor">Lwt_glib</span>.iter</code></a>, then <code class="code">wakeup ()</code> make
      <a href="Lwt_glib.html#VALiter"><code class="code"><span class="constructor">Lwt_glib</span>.iter</code></a> to return immediatly.<br>
</div>
</body></html>