mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 03:05:28 -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 'event sink = 'event -> unit
|
||||
|
||||
and 'a transition =
|
||||
| TransitionTo of 'a
|
||||
| TransitionStay
|
||||
|
|
@ -166,7 +164,7 @@ let filter st p =
|
|||
Weak.set a 0 (Some st');
|
||||
register_while st
|
||||
(fun _ new_state ->
|
||||
if p
|
||||
if p new_state
|
||||
then begin match Weak.get a 0 with
|
||||
| None -> false
|
||||
| Some st' ->
|
||||
|
|
|
|||
12
CSM.mli
12
CSM.mli
|
|
@ -36,9 +36,6 @@ type 'state t
|
|||
(** State machine, whose states are of the type 'state,
|
||||
and that changes state upon events of the type 'event. *)
|
||||
|
||||
type 'event sink
|
||||
(** Something that reacts to events of type 'events *)
|
||||
|
||||
type 'a transition =
|
||||
| TransitionTo of 'a
|
||||
| TransitionStay
|
||||
|
|
@ -48,7 +45,7 @@ type 'a transition =
|
|||
val create : ?root:bool ->
|
||||
init:'state ->
|
||||
trans:('state -> 'event -> 'state transition) ->
|
||||
'state t * 'event sink
|
||||
'state t * ('event -> unit)
|
||||
(** Creation of a state machine with an initial state and a
|
||||
given transition function. [root] specifies whether the FSM should
|
||||
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
|
||||
(** 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
|
||||
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} *)
|
||||
|
||||
val map : 'a t -> ('a -> 'b) -> 'b t
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue