Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/c-cube/fuseau
[alpha] lightweight fiber library for OCaml 5
https://github.com/c-cube/fuseau
effects fibers libuv ocaml ocaml5
Last synced: 3 months ago
JSON representation
[alpha] lightweight fiber library for OCaml 5
- Host: GitHub
- URL: https://github.com/c-cube/fuseau
- Owner: c-cube
- Created: 2023-11-01T03:20:27.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-02-29T04:04:36.000Z (11 months ago)
- Last Synced: 2024-04-20T00:54:15.780Z (9 months ago)
- Topics: effects, fibers, libuv, ocaml, ocaml5
- Language: OCaml
- Homepage: https://c-cube.github.io/fuseau/
- Size: 3.37 MB
- Stars: 13
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGES.md
Awesome Lists containing this project
README
# Fuseau
This is an experimental concurrency/IO library for OCaml 5. Currently the only backend is a naive one
using `Unix.select` but I plan to add more robust ones.A basic example that spins 4 concurrent loops in direct style:
```ocaml
# let spf = Printf.sprintf
val spf : ('a, unit, string) format -> 'a =# let main () =
print_endline "entering main";let computations =
Array.init 4 (fun j ->
Fuseau.spawn @@ fun () ->
print_endline @@ spf "spawn fiber %d" j;
for i = 1 to 3 do
(* this suspends the fiber for 500ms *)
Fuseau.sleep_s 0.5;
print_endline @@ spf "iter %d (fiber %d)" i j
done)
in(* wait for the loops to end *)
Array.iter Fuseau.await computations;
print_endline "done"
val main : unit -> unit =# let () = Fuseau_unix.main main
entering main
spawn fiber 0
spawn fiber 1
spawn fiber 2
spawn fiber 3
iter 1 (fiber 0)
iter 1 (fiber 1)
iter 1 (fiber 2)
iter 1 (fiber 3)
iter 2 (fiber 0)
iter 2 (fiber 1)
iter 2 (fiber 2)
iter 2 (fiber 3)
iter 3 (fiber 0)
iter 3 (fiber 1)
iter 3 (fiber 2)
iter 3 (fiber 3)
done
```## License
MIT licensed.
## Name
Fuseau ("fuh-zo") is french for a spindle. It's vaguely related to fibers :-)