Skip to content

Commit

Permalink
Fix STM test to build on OCaml 4
Browse files Browse the repository at this point in the history
  • Loading branch information
polytypic committed Apr 2, 2024
1 parent f6752d7 commit 5565737
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 18 deletions.
6 changes: 5 additions & 1 deletion bench/bench_cue.ml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ let run_one ~budgetf ?(n_adders = 2) ?(n_takers = 2)
if n <> 0 then
let rec loop n =
if 0 < n then
loop (n - Bool.to_int (Option.is_some (Queue.pop_opt t)))
match Queue.pop_opt t with
| None ->
Domain.cpu_relax ();
loop n
| Some _ -> loop (n - 1)
else work ()
in
loop n
Expand Down
8 changes: 1 addition & 7 deletions test/cue/dune
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@
(package saturn_lockfree)
(name stm_cue)
(modules stm_cue)
(libraries
saturn
qcheck-core
qcheck-core.runner
qcheck-stm.stm
qcheck-stm.sequential
qcheck-stm.domain)
(libraries saturn qcheck-core qcheck-stm.stm stm_run)
(action
(run %{test} --verbose)))
13 changes: 3 additions & 10 deletions test/cue/stm_cue.ml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ open QCheck
open STM
module Cue = Saturn.Cue

module MSQConf = struct
module Spec = struct
type cmd = Try_push of int | Pop_opt | Peek_opt | Length | Is_empty

let show_cmd c =
Expand Down Expand Up @@ -66,13 +66,6 @@ module MSQConf = struct
| _, _ -> false
end

module MSQ_seq = STM_sequential.Make (MSQConf)
module MSQ_dom = STM_domain.Make (MSQConf)

let () =
let count = 500 in
QCheck_base_runner.run_tests_main
[
MSQ_seq.agree_test ~count ~name:"STM Saturn.Cue test sequential";
MSQ_dom.agree_test_par ~count ~name:"STM Saturn.Cue test parallel";
]
Stm_run.run ~count:500 ~verbose:true ~name:"Saturn_lockfree.Cue" (module Spec)
|> exit

0 comments on commit 5565737

Please sign in to comment.