mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 11:15:31 -05:00
updated csm
This commit is contained in:
parent
53b08fa542
commit
bca08783e1
2 changed files with 3 additions and 13 deletions
4
CSM.ml
4
CSM.ml
|
|
@ -37,8 +37,6 @@ type 'state t = {
|
||||||
|
|
||||||
and 'a sm = 'a t
|
and 'a sm = 'a t
|
||||||
|
|
||||||
and 'event sink = 'event -> unit
|
|
||||||
|
|
||||||
and 'a transition =
|
and 'a transition =
|
||||||
| TransitionTo of 'a
|
| TransitionTo of 'a
|
||||||
| TransitionStay
|
| TransitionStay
|
||||||
|
|
@ -166,7 +164,7 @@ let filter st p =
|
||||||
Weak.set a 0 (Some st');
|
Weak.set a 0 (Some st');
|
||||||
register_while st
|
register_while st
|
||||||
(fun _ new_state ->
|
(fun _ new_state ->
|
||||||
if p
|
if p new_state
|
||||||
then begin match Weak.get a 0 with
|
then begin match Weak.get a 0 with
|
||||||
| None -> false
|
| None -> false
|
||||||
| Some st' ->
|
| Some st' ->
|
||||||
|
|
|
||||||
12
CSM.mli
12
CSM.mli
|
|
@ -36,9 +36,6 @@ type 'state t
|
||||||
(** State machine, whose states are of the type 'state,
|
(** State machine, whose states are of the type 'state,
|
||||||
and that changes state upon events of the type 'event. *)
|
and that changes state upon events of the type 'event. *)
|
||||||
|
|
||||||
type 'event sink
|
|
||||||
(** Something that reacts to events of type 'events *)
|
|
||||||
|
|
||||||
type 'a transition =
|
type 'a transition =
|
||||||
| TransitionTo of 'a
|
| TransitionTo of 'a
|
||||||
| TransitionStay
|
| TransitionStay
|
||||||
|
|
@ -48,7 +45,7 @@ type 'a transition =
|
||||||
val create : ?root:bool ->
|
val create : ?root:bool ->
|
||||||
init:'state ->
|
init:'state ->
|
||||||
trans:('state -> 'event -> 'state transition) ->
|
trans:('state -> 'event -> 'state transition) ->
|
||||||
'state t * 'event sink
|
'state t * ('event -> unit)
|
||||||
(** Creation of a state machine with an initial state and a
|
(** Creation of a state machine with an initial state and a
|
||||||
given transition function. [root] specifies whether the FSM should
|
given transition function. [root] specifies whether the FSM should
|
||||||
be a GC root and stay alive (default false).
|
be a GC root and stay alive (default false).
|
||||||
|
|
@ -77,15 +74,10 @@ val register_while : 'state t -> ('state -> 'state -> bool) -> unit
|
||||||
val register : 'state t -> ('state -> 'state -> unit) -> unit
|
val register : 'state t -> ('state -> 'state -> unit) -> unit
|
||||||
(** Register the given callback forever. *)
|
(** Register the given callback forever. *)
|
||||||
|
|
||||||
val connect : 'a t -> 'a sink -> unit
|
val connect : 'a t -> ('a -> unit) -> unit
|
||||||
(** [connect st sink] connects state changes of [st] to the sink. The
|
(** [connect st sink] connects state changes of [st] to the sink. The
|
||||||
sink is given only the new state of [st]. *)
|
sink is given only the new state of [st]. *)
|
||||||
|
|
||||||
val send : 'event sink -> 'event -> unit
|
|
||||||
(** Trigger an event. This function will not return until no transitions
|
|
||||||
remain for processing, which means it can take an arbitrary amount of time to
|
|
||||||
run. *)
|
|
||||||
|
|
||||||
(** {2 Combinators} *)
|
(** {2 Combinators} *)
|
||||||
|
|
||||||
val map : 'a t -> ('a -> 'b) -> 'b t
|
val map : 'a t -> ('a -> 'b) -> 'b t
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue