Logo

Programming-Idioms

History of Idiom 33 > diff from v19 to v20

Edit summary for version 20 by :
[Pascal] dsgfdfg

Version 19

2016-03-20, 23:33:01

Version 20

2016-03-20, 23:33:23

Idiom #33 Atomically read and update variable

Assign variable x the new value f(x), making sure that no other thread may modify x between the read and the write.

Idiom #33 Atomically read and update variable

Assign variable x the new value f(x), making sure that no other thread may modify x between the read and the write.

Imports
uses syncobjs�;
Imports
uses syncobjs;
Code
var
  loc: TCriticalSection;
begin
  loc.Enter;
  try
    x := f(x);
  finally
    loc.Leave;
  end;
end.�
Code
var
  loc: TCriticalSection;
begin
  loc.Enter;
  try
    x := f(x);
  finally
    loc.Leave;
  end;
end.