File: netsys_global.mli

package info (click to toggle)
ocamlnet 4.1.2-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 51,764 kB
  • ctags: 16,446
  • sloc: ml: 148,419; ansic: 10,989; sh: 1,885; makefile: 1,355
file content (60 lines) | stat: -rw-r--r-- 1,969 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
(* $Id$ *)

(** Global variables

    This module provides a place to store global variables that work
    across subprocess boundaries. In order to push values to related processes
    it needs a [propagator]. The propagator is not included here. The
    Netplex library implements a propagator that is automatically activated.

    Variables are limited to string type.
 *)

type variable

val access : string -> variable
  (** [access name]: Create or look up a variable with this name *)

val get : variable -> string
  (** Get the value of the variable (after checking for an update) *)

val set : variable -> string -> unit
  (** Set the value of the variable *)

val get_v : variable -> string * int64
  (** Get the value and the version number of the variable *)

val set_v : variable -> string -> int64
  (** Set the value and get the new version number *)

val iter : (string -> string -> int64 -> unit) -> unit
  (** [iter f]: for every variable call [f name value version] *)

class type propagator =
  object
    method propagate : string -> string -> int64
      (** [propagate name value version]: push the new [value] of the variable
          called [name] to other processes. The version of the new value is
          returned.
       *)

    method update : string -> int64 -> (string * int64) option
      (** [update name version]: checks whether there is a new value of
          the variable [name] with a version higher than the passed
          [version]. If not, [None] is returned. If so, [Some(val,vers)]
          is returned where [val] is the value with version [vers].
       *)
  end

val get_propagator : unit -> propagator option
  (** Get the current propagator or return [None] *)

val set_propagator : propagator option -> unit
  (** Set the current propagator to [Some p], or remove the propagator with
      [None]
   *)

(**/**)

val internal_set : string -> string -> int64 -> unit
  (* Set the variable without propagation *)