diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c8b17b05..963504a6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -55,8 +55,11 @@ jobs: # temporary until it's in a release - run: opam pin https://github.com/ocaml-multicore/picos.git -y -n + - run: opam pin -y -n lwt 5.9.2 - run: opam install -t moonpool moonpool-lwt --deps-only - run: opam exec -- dune build @install + # install some depopts + - run: opam pin -y -n lwt 6.1.1 - run: opam install thread-local-storage trace domain-local-await - run: opam exec -- dune build --profile=release --force @install @runtest diff --git a/src/lwt/dune b/src/lwt/dune index c6bb5ab3..e9a94982 100644 --- a/src/lwt/dune +++ b/src/lwt/dune @@ -3,8 +3,20 @@ (public_name moonpool-lwt) (enabled_if (>= %{ocaml_version} 5.0)) + (modules moonpool_lwt types_) (libraries (re_export moonpool) picos (re_export lwt) lwt.unix)) + +(executable + (name gen_types_) + (modules gen_types_)) + +(rule + (enabled_if %{lib-available:lwt}) + (deps types_.ml.5 types_.ml.6) + (target types_.ml) + (action + (run ./gen_types_.exe %{version:lwt}))) diff --git a/src/lwt/gen_types_.ml b/src/lwt/gen_types_.ml new file mode 100644 index 00000000..771f0e97 --- /dev/null +++ b/src/lwt/gen_types_.ml @@ -0,0 +1,23 @@ +let copy_file src dst = + let ic = open_in src in + let oc = open_out dst in + let buf = Bytes.create 1024 in + (try + while true do + let n = input ic buf 0 (Bytes.length buf) in + if n = 0 then raise End_of_file; + output oc buf 0 n + done + with End_of_file -> ()); + close_in ic; + close_out oc + +let () = + let version = Sys.argv.(1) in + let major = + try Scanf.sscanf version "%d.%s" (fun maj _ -> maj) with _ -> 0 + in + if major >= 6 then + copy_file "types_.ml.6" "types_.ml" + else + copy_file "types_.ml.5" "types_.ml" diff --git a/src/lwt/moonpool_lwt.ml b/src/lwt/moonpool_lwt.ml index 3293f653..35b75908 100644 --- a/src/lwt/moonpool_lwt.ml +++ b/src/lwt/moonpool_lwt.ml @@ -23,7 +23,7 @@ module Scheduler_state = struct mutable as_runner: Moonpool.Runner.t; mutable enter_hook: Lwt_main.Enter_iter_hooks.hook option; mutable leave_hook: Lwt_main.Leave_iter_hooks.hook option; - mutable notification: int; + mutable notification: Types_.notification; (** A lwt_unix notification to wake up the event loop *) has_notified: bool Atomic.t; } @@ -42,7 +42,7 @@ module Scheduler_state = struct as_runner = Moonpool.Runner.dummy; enter_hook = None; leave_hook = None; - notification = 0; + notification = Types_.dummy_notification; has_notified = Atomic.make false; } diff --git a/src/lwt/types_.ml.5 b/src/lwt/types_.ml.5 new file mode 100644 index 00000000..7b75d8ce --- /dev/null +++ b/src/lwt/types_.ml.5 @@ -0,0 +1,3 @@ + +type notification = int +let dummy_notification : notification = 0 diff --git a/src/lwt/types_.ml.6 b/src/lwt/types_.ml.6 new file mode 100644 index 00000000..0e3eb517 --- /dev/null +++ b/src/lwt/types_.ml.6 @@ -0,0 +1,3 @@ + +type notification = Lwt_unix.notification +let dummy_notification : notification = Lwt_unix.make_notification ignore