From 9df848cd17cb1322e93870a7902ce20d27aab614 Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Mon, 4 Mar 2024 15:48:09 -0500 Subject: [PATCH] breaking: remove `Immediate_runner` it never really supported all that a runner should (effects, scheduling other tasks, etc.) --- src/core/immediate_runner.ml | 20 -------------------- src/core/immediate_runner.mli | 23 ----------------------- src/core/moonpool.ml | 2 +- src/core/moonpool.mli | 8 +++++++- 4 files changed, 8 insertions(+), 45 deletions(-) delete mode 100644 src/core/immediate_runner.ml delete mode 100644 src/core/immediate_runner.mli diff --git a/src/core/immediate_runner.ml b/src/core/immediate_runner.ml deleted file mode 100644 index 56a2cbee..00000000 --- a/src/core/immediate_runner.ml +++ /dev/null @@ -1,20 +0,0 @@ -open Types_ -include Runner - -let run_async_ ~ls:cur_ls f = - TLS.get k_cur_storage := Some cur_ls; - try - let x = f () in - TLS.get k_cur_storage := None; - x - with e -> - let bt = Printexc.get_raw_backtrace () in - TLS.get k_cur_storage := None; - Printexc.raise_with_backtrace e bt - -let runner : t = - Runner.For_runner_implementors.create - ~size:(fun () -> 0) - ~num_tasks:(fun () -> 0) - ~shutdown:(fun ~wait:_ () -> ()) - ~run_async:run_async_ () diff --git a/src/core/immediate_runner.mli b/src/core/immediate_runner.mli deleted file mode 100644 index 0a07d42a..00000000 --- a/src/core/immediate_runner.mli +++ /dev/null @@ -1,23 +0,0 @@ -(** Runner that runs tasks immediately in the caller thread. - - Whenever a task is submitted to this runner via [Runner.run_async r task], - the task is run immediately in the caller thread as [task()]. - There are no background threads, no resource, this is just a trivial - implementation of the interface. - - This can be useful when an implementation needs a runner, but there isn't - enough work to justify starting an actual full thread pool. - - Another situation is when threads cannot be used at all (e.g. because you - plan to call [Unix.fork] later). - - {b NOTE}: this does not handle the [Suspend] effect, so [await], fork-join, - etc. will {b NOT} work on this runner. - - @since 0.5 -*) - -include module type of Runner - -val runner : t -(** The trivial runner that actually runs tasks at the calling point. *) diff --git a/src/core/moonpool.ml b/src/core/moonpool.ml index 1c9cf2e3..b223ae6e 100644 --- a/src/core/moonpool.ml +++ b/src/core/moonpool.ml @@ -25,7 +25,7 @@ module Exn_bt = Exn_bt module Fifo_pool = Fifo_pool module Fut = Fut module Lock = Lock -module Immediate_runner = Immediate_runner +module Immediate_runner = struct end module Runner = Runner module Task_local_storage = Task_local_storage module Thread_local_storage = Thread_local_storage_ diff --git a/src/core/moonpool.mli b/src/core/moonpool.mli index d78f12b6..7a153f0c 100644 --- a/src/core/moonpool.mli +++ b/src/core/moonpool.mli @@ -13,7 +13,13 @@ module Ws_pool = Ws_pool module Fifo_pool = Fifo_pool module Background_thread = Background_thread module Runner = Runner -module Immediate_runner = Immediate_runner + +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}. *) + module Exn_bt = Exn_bt exception Shutdown