mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 11:15:31 -05:00
Lwt_automaton, for an interface with Lwt
This commit is contained in:
parent
be58673ba1
commit
79e40e03a8
8 changed files with 108 additions and 11 deletions
3
_oasis
3
_oasis
|
|
@ -55,7 +55,8 @@ Library "containers_thread"
|
||||||
|
|
||||||
Library "containers_lwt"
|
Library "containers_lwt"
|
||||||
Path: .
|
Path: .
|
||||||
Modules: Behavior
|
Modules: Behavior, Lwt_automaton
|
||||||
|
Pack: true
|
||||||
FindlibName: lwt
|
FindlibName: lwt
|
||||||
FindlibParent: containers
|
FindlibParent: containers
|
||||||
Build$: flag(lwt)
|
Build$: flag(lwt)
|
||||||
|
|
|
||||||
4
_tags
4
_tags
|
|
@ -1,5 +1,5 @@
|
||||||
# OASIS_START
|
# OASIS_START
|
||||||
# DO NOT EDIT (digest: 1f5b1920aa5191df724ab0786999e476)
|
# DO NOT EDIT (digest: cb8d0069d6571765cb2126aec9384e1e)
|
||||||
# Ignore VCS directories, you can use the same kind of rule outside
|
# Ignore VCS directories, you can use the same kind of rule outside
|
||||||
# OASIS_START/STOP if you want to exclude directories that contains
|
# OASIS_START/STOP if you want to exclude directories that contains
|
||||||
# useless stuff for the build process
|
# useless stuff for the build process
|
||||||
|
|
@ -58,6 +58,8 @@
|
||||||
<*.ml{,i}>: package(threads)
|
<*.ml{,i}>: package(threads)
|
||||||
# Library containers_lwt
|
# Library containers_lwt
|
||||||
"containers_lwt.cmxs": use_containers_lwt
|
"containers_lwt.cmxs": use_containers_lwt
|
||||||
|
"behavior.cmx": for-pack(Containers_lwt)
|
||||||
|
"lwt_automaton.cmx": for-pack(Containers_lwt)
|
||||||
<*.ml{,i}>: use_containers
|
<*.ml{,i}>: use_containers
|
||||||
<*.ml{,i}>: package(lwt)
|
<*.ml{,i}>: package(lwt)
|
||||||
<*.ml{,i}>: package(unix)
|
<*.ml{,i}>: package(unix)
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
# OASIS_START
|
# OASIS_START
|
||||||
# DO NOT EDIT (digest: 1374a4df6a056c922bd254bb51737f89)
|
# DO NOT EDIT (digest: 509efa2d48f1db17047d029d9c883d07)
|
||||||
Cache
|
Cache
|
||||||
Deque
|
Deque
|
||||||
Gen
|
Gen
|
||||||
|
|
@ -39,4 +39,5 @@ TTree
|
||||||
HGraph
|
HGraph
|
||||||
Automaton
|
Automaton
|
||||||
Behavior
|
Behavior
|
||||||
|
Lwt_automaton
|
||||||
# OASIS_STOP
|
# OASIS_STOP
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
# OASIS_START
|
# OASIS_START
|
||||||
# DO NOT EDIT (digest: b39a035a995fc6597c8eb942210d1527)
|
# DO NOT EDIT (digest: bc144ef7b5b54947fab9662a822f9179)
|
||||||
Behavior
|
Containers_lwt
|
||||||
# OASIS_STOP
|
# OASIS_STOP
|
||||||
|
|
|
||||||
5
containers_lwt.mlpack
Normal file
5
containers_lwt.mlpack
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
# OASIS_START
|
||||||
|
# DO NOT EDIT (digest: 0baec9dfd3857e8cff12e40cdf9ce7db)
|
||||||
|
Behavior
|
||||||
|
Lwt_automaton
|
||||||
|
# OASIS_STOP
|
||||||
44
lwt_automaton.ml
Normal file
44
lwt_automaton.ml
Normal file
|
|
@ -0,0 +1,44 @@
|
||||||
|
|
||||||
|
(*
|
||||||
|
copyright (c) 2013, simon cruanes
|
||||||
|
all rights reserved.
|
||||||
|
|
||||||
|
redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
redistributions of source code must retain the above copyright notice, this
|
||||||
|
list of conditions and the following disclaimer. redistributions in binary
|
||||||
|
form must reproduce the above copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other materials provided with
|
||||||
|
the distribution.
|
||||||
|
|
||||||
|
this software is provided by the copyright holders and contributors "as is" and
|
||||||
|
any express or implied warranties, including, but not limited to, the implied
|
||||||
|
warranties of merchantability and fitness for a particular purpose are
|
||||||
|
disclaimed. in no event shall the copyright holder or contributors be liable
|
||||||
|
for any direct, indirect, incidental, special, exemplary, or consequential
|
||||||
|
damages (including, but not limited to, procurement of substitute goods or
|
||||||
|
services; loss of use, data, or profits; or business interruption) however
|
||||||
|
caused and on any theory of liability, whether in contract, strict liability,
|
||||||
|
or tort (including negligence or otherwise) arising in any way out of the use
|
||||||
|
of this software, even if advised of the possibility of such damage.
|
||||||
|
*)
|
||||||
|
|
||||||
|
(** {1 interface lwt-automaton} *)
|
||||||
|
|
||||||
|
module I = struct
|
||||||
|
let send f i =
|
||||||
|
Lwt.on_success f (fun x -> Automaton.I.send x i)
|
||||||
|
|
||||||
|
let iter_stream str i =
|
||||||
|
Lwt_stream.iter (fun x -> Automaton.I.send x i) str
|
||||||
|
end
|
||||||
|
|
||||||
|
module O = struct
|
||||||
|
let next o =
|
||||||
|
let fut, send = Lwt.wait () in
|
||||||
|
Automaton.O.once o (Lwt.wakeup send);
|
||||||
|
fut
|
||||||
|
end
|
||||||
|
|
||||||
|
let next_transition a = O.next (Automaton.Instance.transitions a)
|
||||||
45
lwt_automaton.mli
Normal file
45
lwt_automaton.mli
Normal file
|
|
@ -0,0 +1,45 @@
|
||||||
|
|
||||||
|
(*
|
||||||
|
copyright (c) 2013, simon cruanes
|
||||||
|
all rights reserved.
|
||||||
|
|
||||||
|
redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
redistributions of source code must retain the above copyright notice, this
|
||||||
|
list of conditions and the following disclaimer. redistributions in binary
|
||||||
|
form must reproduce the above copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other materials provided with
|
||||||
|
the distribution.
|
||||||
|
|
||||||
|
this software is provided by the copyright holders and contributors "as is" and
|
||||||
|
any express or implied warranties, including, but not limited to, the implied
|
||||||
|
warranties of merchantability and fitness for a particular purpose are
|
||||||
|
disclaimed. in no event shall the copyright holder or contributors be liable
|
||||||
|
for any direct, indirect, incidental, special, exemplary, or consequential
|
||||||
|
damages (including, but not limited to, procurement of substitute goods or
|
||||||
|
services; loss of use, data, or profits; or business interruption) however
|
||||||
|
caused and on any theory of liability, whether in contract, strict liability,
|
||||||
|
or tort (including negligence or otherwise) arising in any way out of the use
|
||||||
|
of this software, even if advised of the possibility of such damage.
|
||||||
|
*)
|
||||||
|
|
||||||
|
(** {1 interface lwt-automaton} *)
|
||||||
|
|
||||||
|
module I : sig
|
||||||
|
val send : 'a Lwt.t -> 'a Automaton.I.t -> unit
|
||||||
|
(** Feed the content of the Lwt value into the automaton input, as soon as
|
||||||
|
available *)
|
||||||
|
|
||||||
|
val iter_stream : 'a Lwt_stream.t -> 'a Automaton.I.t -> unit Lwt.t
|
||||||
|
(** Iterate on the given stream, sending its elements to the automaton *)
|
||||||
|
end
|
||||||
|
|
||||||
|
module O : sig
|
||||||
|
val next : 'a Automaton.O.t -> 'a Lwt.t
|
||||||
|
(** Wait for the next output *)
|
||||||
|
end
|
||||||
|
|
||||||
|
val next_transition :
|
||||||
|
('s,'i,'o) Automaton.Instance.t ->
|
||||||
|
('s * 'i * 's * 'o list) Lwt.t
|
||||||
11
setup.ml
11
setup.ml
|
|
@ -1,7 +1,7 @@
|
||||||
(* setup.ml generated for the first time by OASIS v0.3.0 *)
|
(* setup.ml generated for the first time by OASIS v0.3.0 *)
|
||||||
|
|
||||||
(* OASIS_START *)
|
(* OASIS_START *)
|
||||||
(* DO NOT EDIT (digest: cee801fe92de05606feedd67587200c0) *)
|
(* DO NOT EDIT (digest: 7dab10989ebb7fbf9c63ffe468939fec) *)
|
||||||
(*
|
(*
|
||||||
Regenerated by OASIS v0.4.1
|
Regenerated by OASIS v0.4.1
|
||||||
Visit http://oasis.forge.ocamlcore.org for more information and
|
Visit http://oasis.forge.ocamlcore.org for more information and
|
||||||
|
|
@ -6976,8 +6976,8 @@ let setup_t =
|
||||||
bs_nativeopt = [(OASISExpr.EBool true, [])]
|
bs_nativeopt = [(OASISExpr.EBool true, [])]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
lib_modules = ["Behavior"];
|
lib_modules = ["Behavior"; "Lwt_automaton"];
|
||||||
lib_pack = false;
|
lib_pack = true;
|
||||||
lib_internal_modules = [];
|
lib_internal_modules = [];
|
||||||
lib_findlib_parent = Some "containers";
|
lib_findlib_parent = Some "containers";
|
||||||
lib_findlib_name = Some "lwt";
|
lib_findlib_name = Some "lwt";
|
||||||
|
|
@ -7216,8 +7216,7 @@ let setup_t =
|
||||||
};
|
};
|
||||||
oasis_fn = Some "_oasis";
|
oasis_fn = Some "_oasis";
|
||||||
oasis_version = "0.4.1";
|
oasis_version = "0.4.1";
|
||||||
oasis_digest =
|
oasis_digest = Some "Vjm\254\b\1605[\023\195\024\190\191}\232i";
|
||||||
Some "\184\233\242\020\229\248\226Y\185\173\235\251\207\183\236\221";
|
|
||||||
oasis_exec = None;
|
oasis_exec = None;
|
||||||
oasis_setup_args = [];
|
oasis_setup_args = [];
|
||||||
setup_update = false
|
setup_update = false
|
||||||
|
|
@ -7225,6 +7224,6 @@ let setup_t =
|
||||||
|
|
||||||
let setup () = BaseSetup.setup setup_t;;
|
let setup () = BaseSetup.setup setup_t;;
|
||||||
|
|
||||||
# 7229 "setup.ml"
|
# 7228 "setup.ml"
|
||||||
(* OASIS_STOP *)
|
(* OASIS_STOP *)
|
||||||
let () = setup ();;
|
let () = setup ();;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue