File tree Expand file tree Collapse file tree 5 files changed +34
-4
lines changed Expand file tree Collapse file tree 5 files changed +34
-4
lines changed Original file line number Diff line number Diff line change 6161 ( depends
6262 ( eio ( = :version ) )
6363 ( cstruct-unix ( = dev) )
64+ ( kcas ( and ( >= 0 .3.0) :with -test) )
6465 ( alcotest ( and ( >= 1 .4.0) :with -test) ) ) )
6566( package
6667 (name eio_main)
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ depends: [
1212 "dune" {>= "3.7"}
1313 "eio" {= version}
1414 "cstruct-unix" {= "dev"}
15+ "kcas" {>= "0.3.0" & with-test}
1516 "alcotest" {>= "1.4.0" & with-test}
1617 "odoc" {with-doc}
1718]
Original file line number Diff line number Diff line change @@ -355,8 +355,12 @@ let run ~extra_effects t main x =
355355 let result = ref None in
356356 let `Exit_scheduler =
357357 let new_fiber = Fiber_context. make_root () in
358- fork ~new_fiber (fun () ->
359- result := Some (with_op t main x);
358+ Domain_local_await. using
359+ ~prepare_for_await: Eio.Private.Dla. prepare_for_await
360+ ~while_running: (fun () ->
361+ fork ~new_fiber (fun () ->
362+ result := Some (with_op t main x);
363+ )
360364 )
361365 in
362366 match ! result with
Original file line number Diff line number Diff line change @@ -8,6 +8,6 @@ let () = Jbuild_plugin.V1.send @@ if not win32 then "" else {|
88 (name test)
99 (package eio_windows)
1010 (enabled_if (= %{os_type} "Win32"))
11- (libraries alcotest eio.mock eio_windows))
11+ (libraries alcotest kcas eio.mock eio_windows))
1212
1313|}
Original file line number Diff line number Diff line change @@ -26,10 +26,34 @@ module Random = struct
2626 ]
2727end
2828
29+ module Dla = struct
30+
31+ let test_dla () =
32+ let open Kcas in
33+ let x = Loc. make 0 in
34+ let y = Loc. make 0 in
35+ let foreign_domain = Domain. spawn @@ fun () ->
36+ let x = Loc. get_as (fun x -> Retry. unless (x <> 0 ); x) x in
37+ Loc. set y 22 ;
38+ x
39+ in
40+ Loc. set x 20 ;
41+ let y' = Loc. get_as (fun y -> Retry. unless (y <> 0 ); y) y in
42+ Alcotest. (check int ) " correct y" y' 22 ;
43+ let ans = y' + Domain. join foreign_domain in
44+ Alcotest. (check int ) " answer" ans 42
45+
46+ let tests = [
47+ " dla" , `Quick , test_dla
48+ ]
49+ end
50+
51+
2952let () =
3053 Eio_windows. run @@ fun env ->
3154 Alcotest. run " eio_windows" [
3255 " net" , Test_net. tests env;
3356 " timeout" , Timeout. tests env;
34- " random" , Random. tests env
57+ " random" , Random. tests env;
58+ " dla" , Dla. tests
3559 ]
You can’t perform that action at this time.
0 commit comments