mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 11:15:31 -05:00
small changes
This commit is contained in:
parent
a45fccca98
commit
de7246b75c
2 changed files with 6 additions and 3 deletions
|
|
@ -168,6 +168,7 @@ module Fut = struct
|
||||||
let map f fut =
|
let map f fut =
|
||||||
let res, send = create () in
|
let res, send = create () in
|
||||||
subscribe fut (fun x -> send (f x));
|
subscribe fut (fun x -> send (f x));
|
||||||
|
subscribe res (fun _ -> ignore fut); (* keep ref *)
|
||||||
res
|
res
|
||||||
|
|
||||||
let first l =
|
let first l =
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
(** {2 Behavior tree} *)
|
(** {2 Behavior tree} *)
|
||||||
|
|
||||||
|
(** A behavior tree *)
|
||||||
type tree = private
|
type tree = private
|
||||||
| Test of bool React.event (* test the next occurrence *)
|
| Test of bool React.event (* test the next occurrence *)
|
||||||
| TestFun of (unit -> bool) (* call and test value *)
|
| TestFun of (unit -> bool) (* call and test value *)
|
||||||
|
|
@ -59,12 +60,13 @@ type tree = private
|
||||||
| Select of select_strategy * tree list (* select one subtree *)
|
| Select of select_strategy * tree list (* select one subtree *)
|
||||||
| Parallel of parallel_strategy * tree list (* run all subtrees in parallel *)
|
| Parallel of parallel_strategy * tree list (* run all subtrees in parallel *)
|
||||||
| Closure of (unit -> tree) (* build a tree dynamically *)
|
| Closure of (unit -> tree) (* build a tree dynamically *)
|
||||||
| Succeed
|
| Succeed (* always succeed *)
|
||||||
| Fail
|
| Fail (* always fail *)
|
||||||
(** A behavior tree *)
|
|
||||||
and select_strategy = tree list -> (unit -> tree option)
|
and select_strategy = tree list -> (unit -> tree option)
|
||||||
(** How to select a subtree to run. It may yield a different result each
|
(** How to select a subtree to run. It may yield a different result each
|
||||||
time it is called. *)
|
time it is called. *)
|
||||||
|
|
||||||
and parallel_strategy =
|
and parallel_strategy =
|
||||||
| PSForall (** succeeds when all subtrees succeed *)
|
| PSForall (** succeeds when all subtrees succeed *)
|
||||||
| PSExists (** succeeds when some subtree succeeds (kill the others) *)
|
| PSExists (** succeeds when some subtree succeeds (kill the others) *)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue