mirror of
https://github.com/c-cube/moonpool.git
synced 2025-12-06 11:15:38 -05:00
breaking: make Runner.t abstract
This commit is contained in:
parent
6452ca89d1
commit
a89c0ce4f2
2 changed files with 14 additions and 10 deletions
|
|
@ -1,7 +1,12 @@
|
||||||
(** Moonpool
|
(** Moonpool
|
||||||
|
|
||||||
A pool within a bigger pool (ie the ocean). Here, we're talking about
|
A pool within a bigger pool (ie the ocean). Here, we're talking about
|
||||||
pools of [Thread.t] which live within a fixed pool of [Domain.t].
|
pools of [Thread.t] that are dispatched over several [Domain.t] to
|
||||||
|
enable parallelism.
|
||||||
|
|
||||||
|
We provide several implementations of pools
|
||||||
|
with distinct scheduling strategies, alongside some concurrency
|
||||||
|
primitives such as guarding locks ({!Lock.t}) and futures ({!Fut.t}).
|
||||||
*)
|
*)
|
||||||
|
|
||||||
module Pool = Pool
|
module Pool = Pool
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,13 @@
|
||||||
(** Abstract runner.
|
(** Interface for runners.
|
||||||
|
|
||||||
This provides an abstraction for running tasks in the background.
|
This provides an abstraction for running tasks in the background,
|
||||||
|
which is implemented by various thread pools.
|
||||||
@since 0.3
|
@since 0.3
|
||||||
*)
|
*)
|
||||||
|
|
||||||
type task = unit -> unit
|
type task = unit -> unit
|
||||||
|
|
||||||
type t = private {
|
type t
|
||||||
run_async: task -> unit;
|
|
||||||
shutdown: wait:bool -> unit -> unit;
|
|
||||||
size: unit -> int;
|
|
||||||
num_tasks: unit -> int;
|
|
||||||
}
|
|
||||||
(** A runner.
|
(** A runner.
|
||||||
|
|
||||||
If a runner is no longer needed, {!shutdown} can be used to signal all
|
If a runner is no longer needed, {!shutdown} can be used to signal all
|
||||||
|
|
@ -50,8 +46,11 @@ val run_wait_block : t -> (unit -> 'a) -> 'a
|
||||||
and returns its result. If [f()] raises an exception, then [run_wait_block pool f]
|
and returns its result. If [f()] raises an exception, then [run_wait_block pool f]
|
||||||
will raise it as well.
|
will raise it as well.
|
||||||
|
|
||||||
{b NOTE} be careful with deadlocks (see notes in {!Fut.wait_block}). *)
|
{b NOTE} be careful with deadlocks (see notes in {!Fut.wait_block}
|
||||||
|
about the required discipline to avoid deadlocks). *)
|
||||||
|
|
||||||
|
(** This module is specifically intended for users who implement their
|
||||||
|
own runners. Regular users of Moonpool should not need to look at it. *)
|
||||||
module For_runner_implementors : sig
|
module For_runner_implementors : sig
|
||||||
val create :
|
val create :
|
||||||
size:(unit -> int) ->
|
size:(unit -> int) ->
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue