Logo

Programming-Idioms

History of Idiom 33 > diff from v9 to v10

Edit summary for version 10 by :

Version 9

2015-09-05, 16:32:51

Version 10

2015-09-05, 16:33:31

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