this repo has no description
at main 72 lines 2.3 kB view raw
1(** Multiple isolated execution environments. 2 3 This module provides support for running multiple isolated OCaml 4 evaluation contexts within a single worker. Each environment has 5 its own type environment, allowing independent code execution 6 without interference. 7 8 Libraries are shared across all environments to save memory - once 9 a library is loaded, it's available to all environments. *) 10 11(** {1 Types} *) 12 13type t 14(** An isolated execution environment. *) 15 16type id = string 17(** Environment identifier. *) 18 19(** {1 Environment Management} *) 20 21val create : id -> t 22(** [create id] creates a new environment with the given identifier. 23 The environment starts uninitialized; call [setup] after creation. *) 24 25val get : id -> t option 26(** [get id] returns the environment with the given identifier, if it exists. *) 27 28val get_or_create : id -> t 29(** [get_or_create id] returns the existing environment or creates a new one. *) 30 31val destroy : id -> unit 32(** [destroy id] removes the environment with the given identifier. *) 33 34val list : unit -> id list 35(** [list ()] returns all environment identifiers. *) 36 37val default_id : id 38(** The default environment identifier used when none is specified. *) 39 40val id : t -> id 41(** [id env] returns the identifier of the environment. *) 42 43(** {1 Environment Switching} *) 44 45val with_env : t -> (unit -> 'a) -> 'a 46(** [with_env env f] runs [f ()] in the context of environment [env]. 47 The toplevel environment is saved before and restored after, 48 allowing isolated execution. *) 49 50(** {1 Environment State} *) 51 52val is_setup : t -> bool 53(** [is_setup env] returns whether [setup] has been called for this environment. *) 54 55val mark_setup : t -> unit 56(** [mark_setup env] marks the environment as having completed setup. *) 57 58(** {1 Failed Cells Tracking} *) 59 60module StringSet : Set.S with type elt = string 61 62val get_failed_cells : t -> StringSet.t 63(** [get_failed_cells env] returns the set of cell IDs that failed to compile. *) 64 65val add_failed_cell : t -> string -> unit 66(** [add_failed_cell env cell_id] marks a cell as failed. *) 67 68val remove_failed_cell : t -> string -> unit 69(** [remove_failed_cell env cell_id] marks a cell as no longer failed. *) 70 71val is_cell_failed : t -> string -> bool 72(** [is_cell_failed env cell_id] checks if a cell is marked as failed. *)