package async_kernel

  1. Overview
  2. Docs
Module type
Class type
module type S = sig ... end
module Make (M : Core.Monad.Infix with type 'a t = 'a t) : S with type 'a deferred := 'a M.t
include S with type 'a deferred := 'a t

Memoization functions like in Core.Memo, with re-raising of exceptions thrown asynchronously.

Also see Lazy_deferred, of which Deferred.Memo.unit is a special case.

val general : (module Core.Hashable.S_plain with type t = 'a) -> ('a -> 'b t) -> ('a -> 'b t) Core.Staged.t

general hashable f returns a memoized version of f, where the results are stored in a hash table indexed according to hashable. If f a asynchronously raises, then the error is stored in the hash table and is reraised when a is demanded.

Unlike Core.Memo.general, this general does not support cache_size_bound due to complexities of asynchrony -- even when one has a deferred return by the memoized function, there still may be asynchronous jobs working to determine it.

Unlike Core.Memo.general, this general takes a required Hashable module argument, to avoid unintentional use of polymorphic comparison.

val recursive : (module Core.Hashable.S_plain with type t = 'a) -> (('a -> 'b t) -> 'a -> 'b t) -> ('a -> 'b t) Core.Staged.t

Memoize a recursive asynchronous function. See Memo.recursive for the introduction. We do not implement Async-aware dependency cycle detection, so if recursion is not well-founded then the computation will just deadlock.

val unit : (unit -> 'a t) -> (unit -> 'a t) Core.Staged.t

Innovation. Community. Security.