package ecaml

  1. Overview
  2. Docs
Module type
Class type
val block_on_async : Core.Source_code_position.t -> ?context:Async.Sexp.t Core.Lazy.t -> ?for_testing_allow_nested_block_on_async:bool -> (unit -> 'a Async.Deferred.t) -> 'a

block_on_async here f calls f (), 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.Source_code_position.t -> ?context:Async.Sexp.t Core.Lazy.t -> ?raise_exceptions_to_monitor:Async.Monitor.t -> (unit -> unit Async.Deferred.t) -> unit

enqueue_foreground_block_on_async here f is like block_on_async here f, except that it does not run immediately, and it can be run from inside another block_on_async or an Async job. Async_ecaml will run f at some point, when no other block_on_async is running.

val run_outside_async : Core.Source_code_position.t -> ?allowed_in_background:bool -> (unit -> 'a) -> 'a Async.Deferred.t

run_outside_async f is the idiomatic way to call functions f where f only wraps a single call into Elisp, and f would otherwise raise

"Called [block_on_async] in the middle of an Async job!"


f should do nothing but make the one call into elisp, unless you can show that the work done in OCaml is safe to run with pre-emptive multi-threading semantics.

run_outside_async f schedules f to run at some point in the future, outside of Async, i.e. not during an Async cycle and without holding the Async lock.

This is necessary so that Emacs will run timers and network handlers while waiting for f, and hence will request and run the Async cycles needed by f.

run_outside_asyncN are convenience wrappers around run_outside_async for common function arities. Feel free to add more as necessary.

val run_outside_async1 : Core.Source_code_position.t -> ?allowed_in_background:bool -> ('a -> 'r) -> 'a -> 'r Async.Deferred.t

Innovation. Community. Security.