Logo

Programming-Idioms

History of Idiom 33 > diff from v8 to v9

Edit summary for version 9 by :

Version 8

2015-09-03, 17:05:16

Version 9

2015-09-05, 16:32:51

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
import Control.Concurrent.MVar
Code
putMVar x . f =<< getMVar x
Doc URL
http://hackage.haskell.org/package/base/docs/Control-Concurrent-MVar.html