Skip to content

Commit 0387aa4

Browse files
committed
Add explicit ~xt parameter to Xt.call to make it polymorphic
1 parent bb2571c commit 0387aa4

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

src/kcas/kcas.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,7 @@ module Xt = struct
743743

744744
type 'a tx = { tx : 'x. xt:'x t -> 'a } [@@unboxed]
745745

746-
let call { tx } = tx [@@inline]
746+
let call ~xt { tx } = tx ~xt [@@inline]
747747

748748
let rec add_awaiters awaiter casn = function
749749
| NIL as cont -> cont

src/kcas/kcas.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ module Xt : sig
345345
explicit transaction log. The universal quantification helps to ensure
346346
that the transaction log cannot accidentally escape. *)
347347

348-
val call : 'a tx -> xt:'x t -> 'a
348+
val call : xt:'x t -> 'a tx -> 'a
349349
(** [call ~xt tx] is equivalent to [tx.Xt.tx ~xt]. *)
350350

351351
val commit : ?backoff:Backoff.t -> ?mode:Mode.t -> 'a tx -> 'a

test/kcas/test.ml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,15 @@ let test_rollback () =
555555

556556
(* *)
557557

558+
let test_call () =
559+
let never = Xt.{ tx = (fun ~xt:_ -> Retry.later ()) } in
560+
let result =
561+
Xt.commit { tx = Xt.first [ Xt.call never; (fun ~xt:_ -> 101) ] }
562+
in
563+
assert (result = 101)
564+
565+
(* *)
566+
558567
let test_mode () =
559568
assert (Loc.get_mode (Loc.make ~mode:Mode.lock_free 0) == Mode.lock_free);
560569
assert (
@@ -598,6 +607,7 @@ let () =
598607
test_periodic_validation ();
599608
test_explicit_validation ();
600609
test_rollback ();
610+
test_call ();
601611
test_mode ();
602612
test_xt ();
603613
Printf.printf "Test suite OK!\n%!"

0 commit comments

Comments
 (0)