package picos
Pico scheduler interface
Install
Dune Dependency
Authors
Maintainers
Sources
picos-0.4.0.tbz
sha256=343a8b4759239ca0c107145b8e2cc94c14625fecc0b0887d3c40a9ab7537b8da
sha512=db22b0a5b3adc603c0e815c9011c779f892b9ace76be018b2198d3e24a7d96727c999701025fe5a5fd07d0b452cb7286fc50c939aba0e4dce809941e9ebc12a6
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 @@ fun () ->
let@ msg_i, msg_o =
finally Unix.close_pair @@ fun () ->
Unix.socketpair ~cloexec:true
PF_UNIX SOCK_STREAM 0
in
let@ syn_i, syn_o =
finally Unix.close_pair @@ fun () ->
Unix.socketpair ~cloexec:true
PF_UNIX SOCK_STREAM 0
in
Unix.set_nonblock msg_i;
Unix.set_nonblock msg_o;
Unix.set_nonblock syn_i;
Unix.set_nonblock syn_o;
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_i bytes 0 100
in
if n > 0 then begin
Printf.printf "%s\n%!"
(Bytes.sub_string bytes 0 n);
let w =
Unix.write_substring
syn_o "!" 0 1
in
assert (w = 1)
end
done
end;
let send_string s =
let n = String.length s in
let w =
Unix.write_substring msg_o s 0 n
in
assert (w = n);
let r =
Unix.read syn_i
(Bytes.create 1) 0 1
in
assert (r = 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