Module Functory.Network.Same.Computation

module Computation: sig .. end

type ('a, 'c) t 

The type of distributed computations.

val create : worker:('a -> 'b) ->
master:('a * 'c -> 'b -> ('a * 'c) list) ->
('a, 'c) t

create worker master creates a new distributed computation. It has no worker, nor tasks. Workers (resp.tasks) should be added using function add_worker (resp. add_task) below. Note: function declare_workers above is only meaningful for high-level API functions such as compute, map, etc. See below.

val add_worker : ('a, 'c) t ->
Network.worker -> unit

add_worker c w adds worker w to computation c.

val add_task : ('a, 'c) t -> 'a * 'c -> unit

add_task c t adds task t to computation c.

val remove_worker : ('a, 'c) t ->
Network.worker -> unit

remove_worker c w removes worker w from computation c. If w was running some task, it will be eventually rescheduled to another worker.

val one_step : ?timeout:float -> ('a, 'c) t -> unit

one_step ~timeout c runs one step of computation c. That is, it

val status : ('a, 'c) t ->

status c queries the statis of computation c. It has three possible values:

val clear : ('a, 'c) t -> unit

clear c clears all tasks from computation c i.e. all pending tasks as well as all currently running tasks. The status of c is set to Done. One can still add new tasks, which will put c back to the Running state.

val kill : ('a, 'c) t -> unit

kill c kills computation c. It turns the status of c to Dead. c cannot be used anymore i.e. any operation applied to c will raise an Invalid_argument exception.