Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor fixes in lwt-tutorial and lwt-exrercises #17

Merged
merged 1 commit into from Sep 23, 2011
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion slides/lwt_exercises.ml
Expand Up @@ -32,7 +32,7 @@ $str:dl$ make mysleep
<ul>
<li><tt>OS.Time.sleep tm</tt> will sleep for <tt>tm</tt> seconds.</li>
<li><tt>OS.Console.log</tt> and <tt>OS.Console.log_s</tt> (the Lwt version) print a string to console.</li>
<li><a href="http://ocsigen.org/lwt/api/Lwt#VALchoose"><tt>Lwt.choose</tt></a> waits for multiple threads to finish.</li>
<li><a href="http://ocsigen.org/lwt/api/Lwt#VALjoin"><tt>Lwt.join</tt></a> waits for multiple threads to finish.</li>
</ul>
>>
};
Expand Down
10 changes: 5 additions & 5 deletions slides/lwt_tutorial.ml
Expand Up @@ -56,7 +56,7 @@ val return : 'a -> 'a Lwt.t
<section><pre>
val bind : 'a Lwt.t -> ('a -> 'b Lwt.t) -> 'b Lwt.t
</pre></section>
<p><tt><a href="http://ocsigen.org/lwt/api/Lwt#VALbind">Lwt.bind</a> t f</tt> creates a thread which waits for <tt>t</tt> to terminate, then pass the result to <tt>f</tt>. If <tt>t</tt> is a sleeping thread, then <tt>bind t f</tt> will sleep too, until <t>t terminates</t>.</p>
<p><tt><a href="http://ocsigen.org/lwt/api/Lwt#VALbind">Lwt.bind</a> t f</tt> creates a thread which waits for <tt>t</tt> to terminate, then pass the result to <tt>f</tt>. If <tt>t</tt> is a sleeping thread, then <tt>bind t f</tt> will sleep too, until <tt>t</tt> terminates.</p>
<section><pre>
val join : unit Lwt.t list -> unit Lwt.t
</pre></section>
Expand All @@ -82,7 +82,7 @@ val join : unit Lwt.t list -> unit Lwt.t
<pre>
lwt () = OS.Time.sleep 1.0 in
lwt () = OS.Time.sleep 2.0 in
OS.Console.log "Wake up sleep!\n";
OS.Console.log "Wake up sleepy!\n";
Lwt.return ()</pre>
>>
};
Expand All @@ -94,15 +94,15 @@ val join : unit Lwt.t list -> unit Lwt.t
<pre>
lwt () = OS.Time.sleep 1.0 in
lwt () = OS.Time.sleep 2.0 in
OS.Console.log "Wake up sleep!\n";
OS.Console.log "Wake up sleepy!\n";
Lwt.return ()</pre>
<p>After syntax transform: (<tt>make sleep.pp</tt>)</p>
<pre>
let __pa_lwt_0 = OS.Time.sleep 1.0 in
Lwt.bind __pa_lwt_0 (fun () ->
let __pa_lwt_0 = OS.Time.sleep 2.0 in
Lwt.bind __pa_lwt_0 (fun () ->
(OS.Console.log "Wake up sleep.ml!\n";
(OS.Console.log "Wake up sleepy!\n";
Lwt.return ()
)
)
Expand All @@ -121,7 +121,7 @@ val join : unit Lwt.t list -> unit Lwt.t
<pre>
let t,u = Lwt.task () in // t sleeps forever
Lwt.wakeup u "foo"; // and u can wake it up
t // value of t is "foo" </pre>
t // value carried by t is "foo" </pre>
<p>The outside world wakes up sleeping threads via the <tt><a href="http://ocsigen.org/lwt/api/Lwt#VALwakeup">Lwt.wakeup</a></tt> mechanism:</p>
<ul>
<li>Timeouts are stored in an efficient <a href="https://github.com/avsm/mirage/blob/master/lib/os/unix/time.ml">priority queue</a></li>
Expand Down