This commit is contained in:
Pavel 2022-06-07 16:23:43 +03:00
parent c1e230cc5a
commit 23293839ea

View File

@ -71,7 +71,8 @@ implementation
Uses Uses
atomic, atomic,
sys_kernel; sys_kernel,
sys_signal;
Procedure backoff_exp.Wait; Procedure backoff_exp.Wait;
Var Var
@ -177,6 +178,7 @@ end;
function spin_trylock(var t:r_spin_lock):Boolean; function spin_trylock(var t:r_spin_lock):Boolean;
begin begin
Result:=True; Result:=True;
_sig_lock;
if spin_trylock(t._lock) then if spin_trylock(t._lock) then
begin begin
t.count:=0; t.count:=0;
@ -189,6 +191,7 @@ begin
begin begin
Result:=False; Result:=False;
end; end;
_sig_unlock;
end; end;
procedure spin_lock(var t:r_spin_lock); procedure spin_lock(var t:r_spin_lock);
@ -201,15 +204,16 @@ end;
procedure spin_unlock(var t:r_spin_lock); procedure spin_unlock(var t:r_spin_lock);
begin begin
if (t.count<=1) then _sig_lock;
if (t.count=0) then
begin begin
t.count:=0;
t.owner:=DWORD(-1); t.owner:=DWORD(-1);
spin_unlock(t._lock); spin_unlock(t._lock);
end else end else
begin begin
Dec(t.count); Dec(t.count);
end; end;
_sig_unlock;
end; end;
// //