Skip to content

Commit

Permalink
Bump saturn.
Browse files Browse the repository at this point in the history
  • Loading branch information
toots committed Aug 23, 2024
1 parent 00cad0d commit 9ff2eb3
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .github/scripts/build-posix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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::"
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion dune-project
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion liquidsoap-lang.opam
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
49 changes: 25 additions & 24 deletions src/lang/queues.ml
Original file line number Diff line number Diff line change
Expand Up @@ -25,41 +25,42 @@ 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 =
let flush_fold_f ret el = fn el ret in
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)
Expand Down Expand Up @@ -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
3 changes: 3 additions & 0 deletions src/lang/queues.mli
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9ff2eb3

Please sign in to comment.