mirror of
https://github.com/c-cube/moonpool.git
synced 2025-12-06 03:05:30 -05:00
perf fut: use Domain_.relax in spin loops
This commit is contained in:
parent
f3228f87c7
commit
259fee2722
1 changed files with 14 additions and 9 deletions
23
src/fut.ml
23
src/fut.ml
|
|
@ -39,7 +39,7 @@ let on_result (self : _ t) (f : _ waiter) : unit =
|
||||||
let must_retry = not (A.compare_and_set self.st st (Waiting (f :: l))) in
|
let must_retry = not (A.compare_and_set self.st st (Waiting (f :: l))) in
|
||||||
must_retry
|
must_retry
|
||||||
do
|
do
|
||||||
()
|
Domain_.relax ()
|
||||||
done
|
done
|
||||||
|
|
||||||
exception Already_fulfilled
|
exception Already_fulfilled
|
||||||
|
|
@ -58,7 +58,7 @@ let fulfill (self : _ t) (r : _ result) : unit =
|
||||||
) else
|
) else
|
||||||
true
|
true
|
||||||
do
|
do
|
||||||
()
|
Domain_.relax ()
|
||||||
done
|
done
|
||||||
|
|
||||||
let[@inline] fulfill_idempotent self r =
|
let[@inline] fulfill_idempotent self r =
|
||||||
|
|
@ -137,13 +137,18 @@ let bind ?on ~f fut : _ t =
|
||||||
|
|
||||||
fut2
|
fut2
|
||||||
|
|
||||||
let rec update_ (st : 'a A.t) f : 'a =
|
let update_ (st : 'a A.t) f : 'a =
|
||||||
let x = A.get st in
|
let rec loop () =
|
||||||
let y = f x in
|
let x = A.get st in
|
||||||
if A.compare_and_set st x y then
|
let y = f x in
|
||||||
y
|
if A.compare_and_set st x y then
|
||||||
else
|
y
|
||||||
update_ st f
|
else (
|
||||||
|
Domain_.relax ();
|
||||||
|
loop ()
|
||||||
|
)
|
||||||
|
in
|
||||||
|
loop ()
|
||||||
|
|
||||||
let both a b : _ t =
|
let both a b : _ t =
|
||||||
match peek a, peek b with
|
match peek a, peek b with
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue