Skip to content

Commit 9a9c02b

Browse files
committed
Support DLA on Windows
1 parent e5b57fa commit 9a9c02b

File tree

5 files changed

+34
-4
lines changed

5 files changed

+34
-4
lines changed

dune-project

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
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)

eio_windows.opam

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff 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
]

lib_eio_windows/sched.ml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff 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

lib_eio_windows/test/dune

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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
|}

lib_eio_windows/test/test.ml

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,34 @@ module Random = struct
2626
]
2727
end
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+
2952
let () =
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
]

0 commit comments

Comments
 (0)