package picos
Pico scheduler framework
Install
Dune Dependency
Authors
Maintainers
Sources
picos-0.3.0.tbz
sha256=544804c0bde4b29764f82f04e7defed7c06bc43e5a6ce3f7fdc326cb54a7f066
sha512=4c93427e477fb52374a554a8b9c4c92836a9b5899161275d1473269ab526a1f59177209140631ed763a55be375855dea12f076e18bf4124522414986c0e257be
doc/picos.stdio/Picos_stdio/index.html
Module Picos_stdio
Source
Basic IO facilities based on OCaml standard libraries for Picos
.
Modules
A transparently asynchronous replacement for a subset of the Unix
module that comes with OCaml.
Examples
First we open some modules for convenience:
open Picos_structured.Finally
open Picos_structured
open Picos_stdio
A pair of pipes
Here is a simple example of two fibers communicating through a pair of pipes:
# Picos_fifos.run ~forbid:false @@ fun () ->
let@ msg_inn, msg_out =
finally Unix.close_pair @@ fun () ->
Unix.socketpair PF_UNIX SOCK_STREAM 0 ~cloexec:true
in
let@ syn_inn, syn_out =
finally Unix.close_pair @@ fun () ->
Unix.socketpair PF_UNIX SOCK_STREAM 0 ~cloexec:true
in
Unix.set_nonblock msg_inn;
Unix.set_nonblock msg_out;
Unix.set_nonblock syn_inn;
Unix.set_nonblock syn_out;
Bundle.join_after begin fun bundle ->
Bundle.fork bundle begin fun () ->
let bytes = Bytes.create 100 in
while true do
let n = Unix.read msg_inn bytes 0 100 in
if n > 0 then begin
Printf.printf "%s\n%!" (Bytes.sub_string bytes 0 n);
assert (1 = Unix.write_substring syn_out "!" 0 1)
end
done
end;
let send_string s =
let n = String.length s in
assert (n = Unix.write_substring msg_out s 0 n);
assert (1 = Unix.read syn_inn (Bytes.create 1) 0 1)
in
send_string "Hello, world!";
send_string "POSIX with OCaml";
Bundle.terminate bundle
end
Hello, world!
POSIX with OCaml
- : unit = ()
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>
On This Page