module Async:sig..end
Async handles allow the user to "wakeup" the event loop and get a callback called from another (system) thread.
type t
include Uwt.Handle
val to_handle : t -> Uwt.Handle.t
val create : (t -> unit) -> t uv_resultCreates a new async handle. The handle is not active immediately. You
have to use Uwt.Async.start
val start : t -> Int_result.unitThis will increase the reference count of the async handle. Uwt.Main.run
will wait until send is called, if there are no other pendings tasks.
val stop : t -> Int_result.unitDecrease the reference count again
val send : t -> Int_result.unitWakeup the event loop and call the async handle's callback.
It's safe to call this function from any system thread. The callback
will be called on the loop thread. Uwt.Async.create, Uwt.Async.start, and Uwt.Async.stop
however must be called from the main thread.
Warning: libuv will coalesce calls to Uwt.Async.send, that is, not every
call to it will yield an execution of the callback. For example:
if Uwt.Async.send is called 5 times in a row before the callback is
called, the callback will only be called once. If Uwt.Async.send is
called again after the callback was called, it will be called
again.