package fuseau
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=8a9339d239aa371d0c4aceb23d7601a1b7da8f42d84542cee30669cc95addb6a
sha512=fa656c7311371344f0c6ebf08c666afc33296558ccc678ed87baf2f9ba54035cd4c5caca4257212416296fcdbdfc1687c46cc2ebea3548c792ea72602b85b832
doc/fuseau.unix/Fuseau_unix/index.html
Module Fuseau_unix
Source
Simple event loop based on Unix.select
.
This library combines Fuseau
's fibers with a simple event loop for IOs based on Unix.select
. It's useful for simple situations or portability. For bigger system it's probably better to use another event loop.
include module type of struct include Fuseau end
Foundations
The unique name of a fiber
Atomic events.
See Event.select
.
Synchronization
Basic channels
Utils
Exception with backtrace
Time measurement
Fibers.
Fiber-local storage.
IO event loop
Exception raised when trying to perform operations on the scheduler after it's been disposed of
Scheduler that runs fibers.
Resource management
Resource pool.
A pool of buffers to reuse.
IO streams
IO streams.
Sleep
Put the current fiber to sleep for that many seconds.
Re-exports
Exception used for cancellation caused by timeout
Wait for the fiber to terminate, and return the result. If the fiber failed, this re-raises the exception.
This must be called from inside another fiber, which will be suspended if needed.
Like await
but catches exceptions.
Cancel the current fiber after delay
seconds, unless the fiber terminates first. The cancellation will use the Timeout
exception.
ev_timeout duration
is an event that resolves after duration
seconds with a Error Timeout
error
ev_deadline time
is an event that resolves at monotonic time t
with a Error Timeout
error
let@ () = with_cancel_callback cb in <e>
evaluates e
in a scope in which, if the current fiber is cancelled, cb()
is called. If e
returns without the fiber being cancelled, this callback is removed.
Must be run from inside the scheduler's thread. Spawn a new computation. This fiber has an implicit parent, which is normally the currently running fiber (the one calling spawn
). If the parent fails or is cancelled, the resulting fiber will also be cancelled (parent to child).
Spawn a task from anywhere, possibly from another thread. The task will run in a subsequent call to run_iteration
in the scheduler's thread. Thread-safe, more costly than spawn
. Runs under the root switch.
val spawn_as_child_of :
?name:string ->
?propagate_cancel_to_parent:bool ->
Scheduler.t ->
_ Fiber.t ->
(unit -> 'a) ->
'a Fiber.t
Spawn a fiber in the given parent fiber's scope. See spawn
for more details on the arguments
Must be run from inside a Scheduler.t
's thread. Schedules a microtask that will run in this tick. Be careful not to create infinite sequences of micro tasks that starve the IO loop!
These microtasks do not handle effects and should try their best to not raise exceptions. Only use them for very short amount of work.
Not thread-safe.
yield ()
returns control to the scheduler and checks for cancellation. This must be called from a fiber.
This returns the scheduler on which the caller runs. It must be called from inside a fiber.
Main loop.
This is the loop that runs both fibers, and the IO event loop, in an interspersed way.
A version of Fuseau.main
that uses a Unix-based event loop.