Skip to content

Commit

Permalink
Tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
polytypic committed Nov 24, 2024
1 parent b69dc72 commit 5575fa1
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions src/kcas/kcas.ml
Original file line number Diff line number Diff line change
Expand Up @@ -396,9 +396,9 @@ let block loc before =
if add_awaiter loc before t then
match Trigger.await t with
| None -> ()
| Some (exn, bt) ->
| Some exn_bt ->
remove_awaiter Backoff.default loc before t;
Printexc.raise_with_backtrace exn bt
Printexc.raise_with_backtrace (fst exn_bt) (snd exn_bt)

let rec update_no_alloc backoff loc state f =
(* Fenceless is safe as we have had a fence before if needed and there is a fence after. *)
Expand Down Expand Up @@ -888,37 +888,39 @@ module Xt = struct
| None ->
remove_awaiters t xt (T Leaf) root |> ignore;
commit_reset_reuse backoff xt tx
| Some (exn, bt) ->
| Some exn_bt ->
remove_awaiters t xt (T Leaf) root |> ignore;
Printexc.raise_with_backtrace exn bt
Printexc.raise_with_backtrace (fst exn_bt) (snd exn_bt)
end
| T (Node _) as stop ->
remove_awaiters t xt stop root |> ignore;
commit_once_reuse backoff xt tx
end
end

and commit_once_reuse backoff xt tx =
check xt;
commit_reuse (Backoff.once backoff) xt tx

and commit_reset_reuse backoff xt tx =
and commit_once_reuse backoff (Xt xt_r as xt : _ t) tx =
tree_as_ref xt := T Leaf;
xt_r.validate_counter <- initial_validate_period;
xt_r.post_commit <- Action.noop;
let backoff = Backoff.once backoff in
check xt;
commit_reuse (Backoff.reset backoff) xt tx
commit backoff xt tx

and commit_reuse backoff (Xt xt_r as xt : _ t) tx =
and commit_reset_reuse backoff (Xt xt_r as xt : _ t) tx =
tree_as_ref xt := T Leaf;
xt_r.validate_counter <- initial_validate_period;
xt_r.post_commit <- Action.noop;
let backoff = Backoff.reset backoff in
check xt;
commit backoff xt tx

and commit_once_alloc backoff mode (Xt xt_r as xt : _ t) tx =
check xt;
let backoff = Backoff.once backoff in
and commit_once_alloc backoff mode (Xt xt_r : _ t) tx =
let rot = U Leaf in
let validate_counter = initial_validate_period in
let post_commit = Action.noop in
let xt = Xt { xt_r with rot; mode; validate_counter; post_commit } in
let backoff = Backoff.once backoff in
check xt;
commit backoff xt tx

let[@inline] commit ?(backoff = Backoff.default) ?(mode = `Obstruction_free)
Expand Down

0 comments on commit 5575fa1

Please sign in to comment.