Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
up to date with the journal revision
- Loading branch information
Showing
18 changed files
with
432 additions
and
525 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
open Session | ||
|
||
type result = Result (*stub*) | ||
type credential = Cred (*stub*) | ||
let bad_credential Cred = false (*stub*) | ||
let do_query (query:string) : result = Result (*stub*) | ||
|
||
let db_ch = new_channel () | ||
and worker_ch = new_channel () | ||
|
||
let rec main () = | ||
accept db_ch ~bindto:_0 >> | ||
recv _0 >>= fun cred -> | ||
if bad_credential cred then | ||
select_left _0 >> | ||
close _0 | ||
else | ||
select_right _0 >> | ||
connect worker_ch ~bindto:_1 >> | ||
deleg_send _1 ~release:_0 >> | ||
close _1 >>= | ||
main | ||
|
||
let rec worker () = | ||
accept worker_ch ~bindto:_0 >> | ||
deleg_recv _0 ~bindto:_1 >> | ||
close _0 >> | ||
let rec loop () = | ||
branch | ||
~left:(_1, fun () -> close _1) | ||
~right:(_1, fun () -> | ||
recv _1 >>= fun query -> | ||
let res = do_query query in | ||
send _1 res >>= | ||
loop) | ||
in loop () >>= worker |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
open Session | ||
let xor : bool -> bool -> bool = (<>) | ||
let print_bool = Printf.printf "%B" | ||
let xor_ch = new_channel ();; | ||
Thread.create | ||
(accept_ xor_ch (fun () -> | ||
recv s >>= fun (x,y) -> | ||
send s (xor x y) >> | ||
close s)) ();; | ||
connect_ xor_ch (fun () -> | ||
send s (false,true) >> | ||
recv s >>= fun b -> | ||
print_bool b; | ||
close s) () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
open Session | ||
let xor : bool -> bool -> bool = (<>) | ||
let print_bool = Printf.printf "%B" | ||
type binop = And | Or | Xor | Imp | ||
let log_ch = new_channel () | ||
let eval_op = function | ||
| And -> (&&) | ||
| Or -> (||) | ||
| Xor -> xor | ||
| Imp -> (fun a b -> not a || b) | ||
let rec logic_server () = | ||
branch ~left:(s, fun () -> | ||
recv s >>= fun op -> | ||
recv s >>= fun (x,y) -> | ||
send s (eval_op op x y) >>= fun () -> | ||
logic_server ()) | ||
~right:(s, fun () -> close s);; | ||
Thread.create | ||
(accept_ log_ch logic_server) ();; | ||
connect_ log_ch (fun () -> | ||
select_left s >> | ||
send s And >> | ||
send s (true, false) >> | ||
recv s >>= fun ans -> | ||
(print_bool ans; | ||
select_right s >> | ||
close s)) () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
open Session | ||
open Example_journal2 | ||
let worker_ch = new_channel () | ||
let rec main () = | ||
accept log_ch ~bindto:_0 >> | ||
connect worker_ch ~bindto:_1 >> | ||
deleg_send _1 ~release:_0 >> | ||
close _1 >>= fun () -> | ||
main () | ||
let rec worker () = | ||
accept worker_ch ~bindto:_1 >> | ||
deleg_recv _1 ~bindto:_0 >> | ||
close _1 >> | ||
logic_server () >>= fun () -> | ||
worker ();; | ||
for i = 0 to 5 do | ||
Thread.create (run worker) () | ||
done;; | ||
Thread.create (run main) ();; | ||
connect_ log_ch (fun () -> | ||
select_left s >> | ||
send s Or >> | ||
send s (true, false) >> | ||
recv s >>= fun ans -> | ||
print_bool ans; print_newline (); | ||
select_left s >> | ||
send s And >> | ||
send s (true, false) >> | ||
recv s >>= fun ans -> | ||
print_bool ans; print_newline (); | ||
select_left s >> | ||
send s Xor >> | ||
send s (true, false) >> | ||
recv s >>= fun ans -> | ||
print_bool ans; print_newline (); | ||
select_right s >> | ||
close s) () | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.