Skip to content

Commit 697ec4e

Browse files
committed
Upgrade to be kcas 0.4.0 compatible
This adapts Reagents to the following changes in kcas: - kcas_data 0.2.4 includes a `Queue` module. - kcas 0.3.0 removed the `Tx` api. - kcas 0.4.0 added an optional `mode` argument to locations.
1 parent 7af1139 commit 697ec4e

File tree

10 files changed

+12
-71
lines changed

10 files changed

+12
-71
lines changed

dune-project

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
(lockfree (>= 0.3.0))
1717
(kcas (>= 0.2.0))
1818
(alcotest (and :with-test (>= 1.6.0)))
19+
(kcas_data (and (>= 0.2.3) :with-test))
1920
)
2021
(synopsis "Composable lock-free data and synchronization structures")
2122
(description "Reagents - Composable lock-free data and synchronization structures"))

lib/postCommitCas.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ module Op = Kcas.Op
1919

2020
type 'a ref = 'a Loc.t
2121

22-
let ref = Loc.make
22+
let ref x = Loc.make x
2323
let get = Loc.get
2424

2525
type cas_kind = Real of Op.t | Imm of bool

reagents.opam

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ depends: [
1515
"lockfree" {>= "0.3.0"}
1616
"kcas" {>= "0.2.0"}
1717
"alcotest" {with-test & >= "1.6.0"}
18+
"kcas_data" {>= "0.2.3" & with-test}
1819
"odoc" {with-doc}
1920
]
2021
build: [

tests/dune

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
(test
3232
(name queue_test)
3333
(modules queue_test)
34-
(libraries reagents references))
34+
(libraries reagents references kcas_data))
3535

3636
(test
3737
(name reagent_queue_test)

tests/queue_test.ml

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -94,22 +94,18 @@ module Test (Q : QUEUE) = struct
9494
Reagents.run (CDL.await b) ()
9595
end
9696

97-
module MakeQ_tx (T : sig
98-
open Kcas
99-
97+
module Make_queue (T : sig
10098
type 'a t
10199

102100
val create : unit -> 'a t
103-
val push : 'a t -> 'a -> unit Tx.t
104-
val pop : 'a t -> 'a option Tx.t
101+
val push : 'a -> 'a t -> unit
102+
val take_opt : 'a t -> 'a option
105103
end) : QUEUE = struct
106-
open Kcas
107-
108104
type 'a t = 'a T.t
109105

110106
let create = T.create
111-
let push queue value = Tx.commit @@ T.push queue value
112-
let pop queue = Tx.commit @@ T.pop queue
107+
let push queue value = T.push value queue
108+
let pop queue = T.take_opt queue
113109
end
114110

115111
let main () =
@@ -123,14 +119,9 @@ let main () =
123119
Printf.printf "Two_lock_queue : mean = %f, sd = %f tp=%f\n%!" m sd
124120
(float_of_int num_items /. m);
125121

126-
let module M = Test (MakeQ_tx (References.Tx_linked_queue)) in
127-
let m, sd = Benchmark.benchmark (fun () -> M.run num_doms items_per_dom) 5 in
128-
Printf.printf "Kcas linked queue : mean = %f, sd = %f tp=%f\n%!" m sd
129-
(float_of_int num_items /. m);
130-
131-
let module M = Test (MakeQ_tx (References.Tx_two_stack_queue)) in
122+
let module M = Test (Make_queue (Kcas_data.Queue)) in
132123
let m, sd = Benchmark.benchmark (fun () -> M.run num_doms items_per_dom) 5 in
133-
Printf.printf "Kcas 2-stack queue : mean = %f, sd = %f tp=%f\n%!" m sd
124+
Printf.printf "Kcas_data.Queue : mean = %f, sd = %f tp=%f\n%!" m sd
134125
(float_of_int num_items /. m);
135126

136127
let module M = Test (MakeQ (Reagents.Data.MichaelScott_queue)) in

tests/references/dune

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
(library
22
(name references)
3-
(libraries kcas unix))
3+
(libraries unix))

tests/references/tx_linked_queue.ml

Lines changed: 0 additions & 23 deletions
This file was deleted.

tests/references/tx_linked_queue.mli

Lines changed: 0 additions & 7 deletions
This file was deleted.

tests/references/tx_two_stack_queue.ml

Lines changed: 0 additions & 15 deletions
This file was deleted.

tests/references/tx_two_stack_queue.mli

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)