aivika-experiment-5.4.1: Simulation experiments for the Aivika library
CopyrightCopyright (c) 2012-2017 David Sorokin <david.sorokin@gmail.com>
LicenseBSD3
MaintainerDavid Sorokin <david.sorokin@gmail.com>
Stabilityexperimental
Safe HaskellSafe-Inferred
LanguageHaskell2010

Simulation.Aivika.Experiment.Concurrent.MVar

Description

Tested with: GHC 8.0.1

The module defines helper functions for working with synchronized variable MVar.

Synopsis

Documentation

maybeReadMVar :: b -> (a -> IO b) -> MVar (Maybe a) -> IO b Source #

Like maybe but for the synchronized variable.

maybePutMVar :: MVar (Maybe a) -> IO a -> (a -> IO b) -> IO b Source #

Update the contents if the variable was empty and then return a result of applying the specified function to either the initial or current value.