@@ -557,8 +557,7 @@ module Xt = struct
557557 type 'x t = {
558558 mutable casn : casn ;
559559 mutable cass : cass ;
560- mutable validate_countdown : int ;
561- mutable validate_period : int ;
560+ mutable validate_counter : int ;
562561 mutable post_commit : Action .t ;
563562 }
564563
@@ -575,16 +574,12 @@ module Xt = struct
575574 validate_one casn loc state;
576575 validate_all casn gt
577576
578- let validate_log xt =
579- let p = xt.validate_period * 2 in
580- xt.validate_countdown < - p;
581- xt.validate_period < - p;
582- validate_all xt.casn xt.cass
583- [@@ inline never]
584-
585577 let maybe_validate_log xt =
586- let c = xt.validate_countdown - 1 in
587- if 0 < c then xt.validate_countdown < - c else validate_log xt
578+ let c0 = xt.validate_counter in
579+ let c1 = c0 + 1 in
580+ xt.validate_counter < - c1;
581+ (* Validate whenever counter reaches next power of 2. *)
582+ if c0 land c1 = 0 then validate_all xt.casn xt.cass
588583 [@@ inline]
589584
590585 let update0 loc f xt lt gt =
@@ -777,8 +772,7 @@ module Xt = struct
777772
778773 let reset_quick xt =
779774 xt.cass < - NIL ;
780- xt.validate_countdown < - initial_validate_period;
781- xt.validate_period < - initial_validate_period;
775+ xt.validate_counter < - initial_validate_period;
782776 xt.post_commit < - Action. noop;
783777 xt
784778 [@@ inline]
@@ -831,10 +825,9 @@ module Xt = struct
831825 let commit ?(backoff = Backoff. default) ?(mode = Mode. obstruction_free) tx =
832826 let casn = Atomic. make (mode :> status )
833827 and cass = NIL
834- and validate_countdown = initial_validate_period
835- and validate_period = initial_validate_period
828+ and validate_counter = initial_validate_period
836829 and post_commit = Action. noop in
837- let xt = { casn; cass; validate_countdown ; post_commit; validate_period } in
830+ let xt = { casn; cass; validate_counter ; post_commit } in
838831 commit backoff mode xt tx.tx
839832 [@@ inline]
840833end
0 commit comments