- type
- TSpinLockCriticalSection = Object
- SectionEmpty : integer;
- Constructor Init;
- Procedure Enter;
- Procedure Leave;
- end;
- implementation
- Constructor TSpinLockCriticalSection.Init;
- begin
- SectionEmpty := 0;
- end;
- Procedure TSpinLockCriticalSection.Enter;
- begin
- While InterlockedExchange(SectionEmpty, 1) <> 0 do
- Sleep(0);
- end;
- Procedure TSpinLockCriticalSection.Leave;
- begin
- InterlockedExchange(SectionEmpty, 0);
- end;