Logo

Programming-Idioms

History of Idiom 33 > diff from v18 to v19

Edit summary for version 19 by :
New Pascal implementation by user [JPSII]

Version 18

2016-02-18, 16:57:58

Version 19

2016-03-20, 23:33:01

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�;
Code
var
  loc: TCriticalSection;
begin
  loc.Enter;
  try
    x := f(x);
  finally
    loc.Leave;
  end;
end.�