We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e96159e commit f79755aCopy full SHA for f79755a
lib/picos_std.awaitable/picos_std_awaitable.mli
@@ -125,17 +125,13 @@ end
125
126
let create ?padded () = Awaitable.make ?padded 0
127
128
- let rec lock t old =
129
- if old <> 0 then begin
130
- Awaitable.await t 2;
131
- lock t (Awaitable.exchange t 2)
132
- end
133
-
134
let lock t =
135
if not (Awaitable.compare_and_set t 0 1) then
136
+ while Awaitable.exchange t 2 <> 0 do
+ Awaitable.await t 2
+ done
137
138
- let unlock ?checked:_ t =
+ let unlock t =
139
let before = Awaitable.fetch_and_add t (-1) in
140
if before = 2 then begin
141
Awaitable.set t 0;
0 commit comments