From 9ff2eb36518880d496cdbae98919a80874dab84f Mon Sep 17 00:00:00 2001 From: Romain Beauxis Date: Fri, 23 Aug 2024 11:54:41 -0500 Subject: [PATCH] Bump saturn. --- .github/scripts/build-posix.sh | 2 +- .github/workflows/ci.yml | 4 +-- dune-project | 2 +- liquidsoap-lang.opam | 2 +- src/lang/queues.ml | 49 +++++++++++++++++----------------- src/lang/queues.mli | 3 +++ 6 files changed, 33 insertions(+), 29 deletions(-) diff --git a/.github/scripts/build-posix.sh b/.github/scripts/build-posix.sh index 1ea3c34773..0d2f1ae66c 100755 --- a/.github/scripts/build-posix.sh +++ b/.github/scripts/build-posix.sh @@ -50,7 +50,7 @@ cd .. opam update opam remove -y jemalloc -opam install -y tls.0.17.4 saturn_lockfree.0.4.1 ppx_hash +opam install -y tls.0.17.4 saturn_lockfree.0.5.0 ppx_hash cd /tmp/liquidsoap-full diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b10082a3f5..11995bc5b0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -75,7 +75,7 @@ jobs: cp PACKAGES.minimal PACKAGES opam update opam pin -yn . - opam install -y saturn_lockfree.0.4.1 ppx_hash + opam install -y saturn_lockfree.0.5.0 ppx_hash opam info -f "depopts:" liquidsoap-core | grep -v osx-secure-transport | xargs opam remove -y inotify ffmpeg-avutil cohttp-lwt-unix prometheus-app ${{ needs.build_details.outputs.minimal_exclude_deps }} opam install -y mem_usage echo "::endgroup::" @@ -111,7 +111,7 @@ jobs: cd /tmp/liquidsoap-full/liquidsoap eval "$(opam config env)" opam update - opam install -y saturn_lockfree.0.4.1 + opam install -y saturn_lockfree.0.5.0 dune build --profile release ./src/js/interactive_js.bc.js tree_sitter_parse: diff --git a/dune-project b/dune-project index e263617e86..babcffa746 100644 --- a/dune-project +++ b/dune-project @@ -148,7 +148,7 @@ (depends (ocaml (>= 4.14)) dune-site - (saturn_lockfree (>= 0.4.1)) + (saturn_lockfree (>= 0.5.0)) (re (>= 1.11.0)) (ppx_string :build) (ppx_hash :build) diff --git a/liquidsoap-lang.opam b/liquidsoap-lang.opam index c54c135f29..394642043e 100644 --- a/liquidsoap-lang.opam +++ b/liquidsoap-lang.opam @@ -11,7 +11,7 @@ depends: [ "dune" {>= "3.6"} "ocaml" {>= "4.14"} "dune-site" - "saturn_lockfree" {>= "0.4.1"} + "saturn_lockfree" {>= "0.5.0"} "re" {>= "1.11.0"} "ppx_string" {build} "ppx_hash" {build} diff --git a/src/lang/queues.ml b/src/lang/queues.ml index 18fb488309..cb8a5e425f 100644 --- a/src/lang/queues.ml +++ b/src/lang/queues.ml @@ -25,11 +25,14 @@ module Queue = struct let flush_elements q = let rec flush_elements_f elements = - try flush_elements_f (pop q :: elements) with Empty -> List.rev elements + match pop_exn q with + | el -> flush_elements_f (el :: elements) + | exception Empty -> List.rev elements in flush_elements_f [] - let pop q = try pop q with Empty -> raise Not_found + let pop q = try pop_exn q with Empty -> raise Not_found + let peek q = try peek_exn q with Empty -> raise Not_found let flush_iter q fn = List.iter fn (flush_elements q) let flush_fold q fn ret = @@ -37,29 +40,27 @@ module Queue = struct List.fold_left flush_fold_f ret (flush_elements q) let elements q = - let rec elements_f l cursor = - match next cursor with - | Some (el, cursor) -> elements_f (el :: l) cursor - | None -> List.rev l + let rec elements_f l = + match pop_exn q with + | el -> elements_f (el :: l) + | exception Empty -> List.rev l in - elements_f [] (snapshot q) + elements_f [] let exists q fn = - let rec exists_f l cursor = - match next cursor with - | Some (el, _) when fn el -> true - | Some (el, cursor) -> exists_f (el :: l) cursor - | None -> false + let rec exists_f () = + match pop_exn q with + | el when fn el -> true + | _ -> exists_f () + | exception Empty -> false in - exists_f [] (snapshot q) + exists_f () let length q = - let rec length_f pos cursor = - match next cursor with - | Some (_, cursor) -> length_f (pos + 1) cursor - | None -> pos + let rec length_f pos = + match pop_exn q with _ -> length_f (pos + 1) | exception Empty -> pos in - length_f 0 (snapshot q) + length_f 0 let iter q fn = List.iter fn (elements q) let fold q fn v = List.fold_left (fun v e -> fn e v) v (elements q) @@ -129,16 +130,16 @@ module WeakQueue = struct let fold q fn v = List.fold_left (fun v e -> fn e v) v (elements q) let filter q fn = - let rec filter_f cursor = - match next cursor with - | Some (el, cursor) -> + let rec filter_f () = + match pop_exn q with + | el -> for i = 0 to Weak.length el - 1 do match Weak.get el i with | Some p when fn p -> () | _ -> Weak.set el i None done; - filter_f cursor - | None -> () + filter_f () + | exception Empty -> () in - filter_f (snapshot q) + filter_f () end diff --git a/src/lang/queues.mli b/src/lang/queues.mli index e16a530a66..7a557565cf 100644 --- a/src/lang/queues.mli +++ b/src/lang/queues.mli @@ -31,7 +31,10 @@ module Queue : sig val pop : 'a t -> 'a val pop_opt : 'a t -> 'a option + + (** Raises [Not_found] when no element can be found. *) val peek : 'a t -> 'a + val peek_opt : 'a t -> 'a option val flush_iter : 'a t -> ('a -> unit) -> unit val flush_fold : 'a t -> ('a -> 'b -> 'b) -> 'b -> 'b