Module Async_ecaml.Private
val block_on_async : Core_kernel.Source_code_position.t -> ?context:Async.Sexp.t Core_kernel.Lazy.t -> ?for_testing_allow_nested_block_on_async:bool -> (unit -> 'a Async.Deferred.t) -> 'a
block_on_async here f
callsf ()
, and runs Async cycles until the result is determined, then returns the result.This function cannot be called:
- during an Async job
- inside another call to
block_on_async
An exception will be raised if these conditions are violated.
val enqueue_foreground_block_on_async : Core_kernel.Source_code_position.t -> ?context:Async.Sexp.t Core_kernel.Lazy.t -> ?raise_exceptions_to_monitor:Async.Monitor.t -> (unit -> unit Async.Deferred.t) -> unit
enqueue_foreground_block_on_async here f
is likeblock_on_async here f
, except that it does not run immediately, and it can be run from inside anotherblock_on_async
or an Async job. Async_ecaml will runf
at some point, when no otherblock_on_async
is running.
val run_outside_async : Core_kernel.Source_code_position.t -> ?allowed_in_background:bool -> (unit -> 'a) -> 'a Async.Deferred.t
run_outside_async f
schedulesf
to run at some point in the future, outside of Async, i.e. not during an Async cycle and without holding the Async lock.run_outside_async
returns a deferred that is filled with the result off
. Userun_outside_async
to wrap blocking Elisp functions, e.g.read-from-minibuffer
. For such functions, Emacs, while waiting, will run timers and network handlers, and hence will run Async cycles. Becauserun_outside_async
runsf
outside of a Async, Emacs will be able to run cycles as needed. Also, becauserun_outside_async
releases the Async lock, the Async scheduler thread will be able to run and request cycles.