From 03b77732cd18b733423e33c48c3be88c0941c700 Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Wed, 20 Mar 2024 15:20:28 -0400 Subject: [PATCH] prepare for 0.6 --- CHANGES.md | 25 +++++++++++++++++++++++++ dune-project | 4 ++-- moonpool-lwt.opam | 4 ++-- moonpool.opam | 2 +- src/core/background_thread.mli | 2 +- src/core/exn_bt.mli | 2 +- src/core/fifo_pool.mli | 2 +- src/core/fut.mli | 8 ++++---- src/core/moonpool.mli | 6 +++--- src/core/runner.mli | 2 +- src/core/task_local_storage.mli | 2 +- src/core/ws_pool.mli | 2 +- src/dpool/moonpool_dpool.mli | 2 +- src/fib/main.mli | 2 +- src/fib/moonpool_fib.ml | 2 +- src/lwt/moonpool_lwt.mli | 4 +++- 16 files changed, 49 insertions(+), 22 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 3e855a20..a295fa77 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,4 +1,29 @@ +# 0.6 + +- breaking: remove `Immediate_runner` (bug prone and didn't + handle effects). `Moonpool_fib.main` can be used to handle + effects in the main function. +- remove deprecated alias `Moonpool.Pool` + +- feat: add structured concurrency sub-library `moonpool.fib` with + fibers. Fibers can use `await` and spawn other fibers that will + be appropriately cancelled when their parent is. +- feat: add add `moonpool-lwt` as an experimental bridge between moonpool and lwt. + This allows moonpool runners to be used from within Lwt to + perform background computations, and conversely to call Lwt from + moonpool with some precautions. +- feat: task-local storage in the main moonpool runners, available from + fibers and regular tasks. +- feat: add `Exn_bt` to core +- feat: add `Runner.dummy` +- make `moonpool.forkjoin` optional (only on OCaml >= 5.0) +- feat: add `Fut.Advanced.barrier_on_abstract_container_of_futures` +- feat: add `Fut.map_list` + +- refactor: split off domain pool to `moonpool.dpool` +- fix too early exit in Ws_pool + # 0.5.1 - fix `Ws_pool`: workers would exit before processing diff --git a/dune-project b/dune-project index ca17aa12..234d03ad 100644 --- a/dune-project +++ b/dune-project @@ -2,7 +2,7 @@ (using mdx 0.2) (name moonpool) -(version 0.5.1) +(version 0.6) (generate_opam_files true) (source (github c-cube/moonpool)) @@ -35,7 +35,7 @@ (package (name moonpool-lwt) - (synopsis "Event loop for moonpool based on Lwt-engine") + (synopsis "Event loop for moonpool based on Lwt-engine (experimental)") (allow_empty) ; on < 5.0 (depends (moonpool (= :version)) diff --git a/moonpool-lwt.opam b/moonpool-lwt.opam index 222d5766..3532ef18 100644 --- a/moonpool-lwt.opam +++ b/moonpool-lwt.opam @@ -1,7 +1,7 @@ # This file is generated by dune, edit dune-project instead opam-version: "2.0" -version: "0.5.1" -synopsis: "Event loop for moonpool based on Lwt-engine" +version: "0.6" +synopsis: "Event loop for moonpool based on Lwt-engine (experimental)" maintainer: ["Simon Cruanes"] authors: ["Simon Cruanes"] license: "MIT" diff --git a/moonpool.opam b/moonpool.opam index c8afba80..dcd9500f 100644 --- a/moonpool.opam +++ b/moonpool.opam @@ -1,6 +1,6 @@ # This file is generated by dune, edit dune-project instead opam-version: "2.0" -version: "0.5.1" +version: "0.6" synopsis: "Pools of threads supported by a pool of domains" maintainer: ["Simon Cruanes"] authors: ["Simon Cruanes"] diff --git a/src/core/background_thread.mli b/src/core/background_thread.mli index 26014389..ea23fabd 100644 --- a/src/core/background_thread.mli +++ b/src/core/background_thread.mli @@ -6,7 +6,7 @@ This is similar to {!Fifo_pool} with exactly one thread. - @since NEXT_RELEASE + @since 0.6 *) include module type of Runner diff --git a/src/core/exn_bt.mli b/src/core/exn_bt.mli index becfbf3b..252b7548 100644 --- a/src/core/exn_bt.mli +++ b/src/core/exn_bt.mli @@ -1,6 +1,6 @@ (** Exception with backtrace. - @since NEXT_RELEASE *) + @since 0.6 *) type t = exn * Printexc.raw_backtrace (** An exception bundled with a backtrace *) diff --git a/src/core/fifo_pool.mli b/src/core/fifo_pool.mli index 28b7a3a9..d7d103cf 100644 --- a/src/core/fifo_pool.mli +++ b/src/core/fifo_pool.mli @@ -36,7 +36,7 @@ val create : (unit -> t, _) create_args @param on_exit_thread called at the end of each worker thread in the pool. @param around_task a pair of [before, after] functions ran around each task. See {!Pool.create_args}. - @param name name for the pool, used in tracing (since NEXT_RELEASE) + @param name name for the pool, used in tracing (since 0.6) *) val with_ : (unit -> (t -> 'a) -> 'a, _) create_args diff --git a/src/core/fut.mli b/src/core/fut.mli index 3b4e4ef4..243afad0 100644 --- a/src/core/fut.mli +++ b/src/core/fut.mli @@ -52,7 +52,7 @@ val fail : exn -> Printexc.raw_backtrace -> _ t val fail_exn_bt : Exn_bt.t -> _ t (** Fail from a bundle of exception and backtrace - @since NEXT_RELEASE *) + @since 0.6 *) val of_result : 'a or_error -> 'a t @@ -85,15 +85,15 @@ val is_done : _ t -> bool val is_success : _ t -> bool (** Checks if the future is resolved with [Ok _] as a result. - @since NEXT_RELEASE *) + @since 0.6 *) val is_failed : _ t -> bool (** Checks if the future is resolved with [Error _] as a result. - @since NEXT_RELEASE *) + @since 0.6 *) val raise_if_failed : _ t -> unit (** [raise_if_failed fut] raises [e] if [fut] failed with [e]. - @since NEXT_RELEASE *) + @since 0.6 *) (** {2 Combinators} *) diff --git a/src/core/moonpool.mli b/src/core/moonpool.mli index 7a153f0c..c0d495c9 100644 --- a/src/core/moonpool.mli +++ b/src/core/moonpool.mli @@ -18,14 +18,14 @@ module Immediate_runner : sig end [@@deprecated "use Moonpool_fib.Main"] (** Runner that runs tasks in the caller thread. - This is removed since NEXT_RELEASE, and replaced by {!Moonpool_fib.Main}. *) + This is removed since 0.6, and replaced by {!Moonpool_fib.Main}. *) module Exn_bt = Exn_bt exception Shutdown (** Exception raised when trying to run tasks on runners that have been shut down. - @since NEXT_RELEASE *) + @since 0.6 *) val start_thread_on_some_domain : ('a -> unit) -> 'a -> Thread.t (** Similar to {!Thread.create}, but it picks a background domain at random @@ -48,7 +48,7 @@ val run_wait_block : ?ls:Task_local_storage.t -> Runner.t -> (unit -> 'a) -> 'a {b NOTE} be careful with deadlocks (see notes in {!Fut.wait_block} about the required discipline to avoid deadlocks). @raise Shutdown if the runner was already shut down - @since NEXT_RELEASE *) + @since 0.6 *) val recommended_thread_count : unit -> int (** Number of threads recommended to saturate the CPU. diff --git a/src/core/runner.mli b/src/core/runner.mli index ce73c333..9a568b8c 100644 --- a/src/core/runner.mli +++ b/src/core/runner.mli @@ -54,7 +54,7 @@ val run_wait_block : ?ls:Task_local_storage.t -> t -> (unit -> 'a) -> 'a val dummy : t (** Runner that fails when scheduling tasks on it. Calling {!run_async} on it will raise Failure. - @since NEXT_RELEASE *) + @since 0.6 *) (** {2 Implementing runners} *) diff --git a/src/core/task_local_storage.mli b/src/core/task_local_storage.mli index 0cb4cc09..a1da0b0f 100644 --- a/src/core/task_local_storage.mli +++ b/src/core/task_local_storage.mli @@ -5,7 +5,7 @@ the current thread. The storage is carried along in case the current task is suspended. - @since NEXT_RELEASE + @since 0.6 *) type t = Types_.local_storage diff --git a/src/core/ws_pool.mli b/src/core/ws_pool.mli index 50a79fe3..3329adba 100644 --- a/src/core/ws_pool.mli +++ b/src/core/ws_pool.mli @@ -45,7 +45,7 @@ val create : (unit -> t, _) create_args before a task is processed, on the worker thread about to run it, and returns [x]; and [after pool x] is called by the same thread after the task is over. (since 0.2) - @param name a name for this thread pool, used if tracing is enabled (since NEXT_RELEASE) + @param name a name for this thread pool, used if tracing is enabled (since 0.6) *) val with_ : (unit -> (t -> 'a) -> 'a, _) create_args diff --git a/src/dpool/moonpool_dpool.mli b/src/dpool/moonpool_dpool.mli index 3a365f3c..35ef918c 100644 --- a/src/dpool/moonpool_dpool.mli +++ b/src/dpool/moonpool_dpool.mli @@ -11,7 +11,7 @@ {b NOTE}: Interface is still experimental. - @since NEXT_RELEASE + @since 0.6 *) type domain = Domain_.t diff --git a/src/fib/main.mli b/src/fib/main.mli index 8d3fa8a9..67e7ad67 100644 --- a/src/fib/main.mli +++ b/src/fib/main.mli @@ -16,7 +16,7 @@ This handles effects, including the ones in {!Fiber}. - @since NEXT_RELEASE + @since 0.6 *) val main : (Moonpool.Runner.t -> 'a) -> 'a diff --git a/src/fib/moonpool_fib.ml b/src/fib/moonpool_fib.ml index 81c274d9..ec89c075 100644 --- a/src/fib/moonpool_fib.ml +++ b/src/fib/moonpool_fib.ml @@ -2,7 +2,7 @@ See {!Fiber} for the most important explanations. - @since NEXT_RELEASE. *) + @since 0.6. *) module Fiber = Fiber module Fls = Fls diff --git a/src/lwt/moonpool_lwt.mli b/src/lwt/moonpool_lwt.mli index ac218e0c..0d171504 100644 --- a/src/lwt/moonpool_lwt.mli +++ b/src/lwt/moonpool_lwt.mli @@ -4,7 +4,9 @@ running [Lwt_main.run] (so, the thread where the Lwt event loop and all Lwt callbacks execute). - @since NEXT_RELEASE *) + {b NOTE}: this is experimental and might change in future versions. + + @since 0.6 *) module Fiber = Moonpool_fib.Fiber module FLS = Moonpool_fib.Fls