Sophie

Sophie

distrib > Mageia > 5 > i586 > media > core-release > by-pkgid > 6e204a966e8c42d976f99a1700ce5f20 > files > 2216

ghc-7.4.2-4.mga5.i586.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Control.Concurrent.MVar</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
window.onload = function () {pageLoad();setSynopsis("mini_Control-Concurrent-MVar.html");};
//]]>
</script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">base-4.5.1.0: Basic libraries</p></div><div id="content"><div id="module-header"><table class="info"><tr><th>Portability</th><td>non-portable (concurrency)</td></tr><tr><th>Stability</th><td>experimental</td></tr><tr><th>Maintainer</th><td>libraries@haskell.org</td></tr><tr><th>Safe Haskell</th><td>Trustworthy</td></tr></table><p class="caption">Control.Concurrent.MVar</p></div><div id="table-of-contents"><p class="caption">Contents</p><ul><li><a href="#g:1"><code>MVar</code>s
</a></li></ul></div><div id="description"><p class="caption">Description</p><div class="doc"><p>An <code><code><a href="Control-Concurrent-MVar.html#t:MVar">MVar</a></code> t</code> is mutable location that is either empty or contains a
 value of type <code>t</code>.  It has two fundamental operations: <code><a href="Control-Concurrent-MVar.html#v:putMVar">putMVar</a></code>
 which fills an <code><a href="Control-Concurrent-MVar.html#t:MVar">MVar</a></code> if it is empty and blocks otherwise, and
 <code><a href="Control-Concurrent-MVar.html#v:takeMVar">takeMVar</a></code> which empties an <code><a href="Control-Concurrent-MVar.html#t:MVar">MVar</a></code> if it is full and blocks
 otherwise.  They can be used in multiple different ways:
</p><ol><li> As synchronized mutable variables,
  2. As channels, with <code><a href="Control-Concurrent-MVar.html#v:takeMVar">takeMVar</a></code> and <code><a href="Control-Concurrent-MVar.html#v:putMVar">putMVar</a></code> as receive and send, and
  3. As a binary semaphore <code><code><a href="Control-Concurrent-MVar.html#t:MVar">MVar</a></code> ()</code>, with <code><a href="Control-Concurrent-MVar.html#v:takeMVar">takeMVar</a></code> and <code><a href="Control-Concurrent-MVar.html#v:putMVar">putMVar</a></code> as
     wait and signal.
</li></ol><p>They were introduced in the paper <a href="Concurrent Haskell.html">Concurrent Haskell</a> by Simon
 Peyton Jones, Andrew Gordon and Sigbjorn Finne, though some details
 of their implementation have since then changed (in particular, a
 put on a full MVar used to error, but now merely blocks.)
</p><ul><li> Applicability
</li></ul><p><code><a href="Control-Concurrent-MVar.html#t:MVar">MVar</a></code>s offer more flexibility than <code>IORef</code>s, but less flexibility
 than <code>STM</code>.  They are appropriate for building synchronization
 primitives and performing simple interthread communication; however
 they are very simple and susceptible to race conditions, deadlocks or
 uncaught exceptions.  Do not use them if you need perform larger
 atomic operations such as reading from multiple variables: use <code>STM</code>
 instead.
</p><p>In particular, the <a href="bigger.html">bigger</a> functions in this module (<code><a href="Control-Concurrent-MVar.html#v:readMVar">readMVar</a></code>,
 <code><a href="Control-Concurrent-MVar.html#v:swapMVar">swapMVar</a></code>, <code><a href="Control-Concurrent-MVar.html#v:withMVar">withMVar</a></code>, <code><a href="Control-Concurrent-MVar.html#v:modifyMVar_">modifyMVar_</a></code> and <code><a href="Control-Concurrent-MVar.html#v:modifyMVar">modifyMVar</a></code>) are simply
 the composition of a <code><a href="Control-Concurrent-MVar.html#v:takeMVar">takeMVar</a></code> followed by a <code><a href="Control-Concurrent-MVar.html#v:putMVar">putMVar</a></code> with
 exception safety.
 These only have atomicity guarantees if all other threads
 perform a <code><a href="Control-Concurrent-MVar.html#v:takeMVar">takeMVar</a></code> before a <code><a href="Control-Concurrent-MVar.html#v:putMVar">putMVar</a></code> as well;  otherwise, they may
 block.
</p><ul><li> Fairness
</li></ul><p>No thread can be blocked indefinitely on an <code><a href="Control-Concurrent-MVar.html#t:MVar">MVar</a></code> unless another
 thread holds that <code><a href="Control-Concurrent-MVar.html#t:MVar">MVar</a></code> indefinitely.  One usual implementation of
 this fairness guarantee is that threads blocked on an <code><a href="Control-Concurrent-MVar.html#t:MVar">MVar</a></code> are
 served in a first-in-first-out fashion, but this is not guaranteed
 in the semantics.
</p><ul><li> Gotchas
</li></ul><p>Like many other Haskell data structures, <code><a href="Control-Concurrent-MVar.html#t:MVar">MVar</a></code>s are lazy.  This
 means that if you place an expensive unevaluated thunk inside an
 <code><a href="Control-Concurrent-MVar.html#t:MVar">MVar</a></code>, it will be evaluated by the thread that consumes it, not the
 thread that produced it.  Be sure to <code><a href="Control-Exception-Base.html#v:evaluate">evaluate</a></code> values to be placed
 in an <code><a href="Control-Concurrent-MVar.html#t:MVar">MVar</a></code> to the appropriate normal form, or utilize a strict
 MVar provided by the strict-concurrency package.
</p><ul><li> Ordering
</li></ul><p><code><a href="Control-Concurrent-MVar.html#t:MVar">MVar</a></code> operations are always observed to take place in the order
 they are written in the program, regardless of the memory model of
 the underlying machine.  This is in contrast to <code>IORef</code> operations
 which may appear out-of-order to another thread in some cases.
</p><ul><li> Example
</li></ul><p>Consider the following concurrent data structure, a skip channel.
 This is a channel for an intermittent source of high bandwidth
 information (for example, mouse movement events.)  Writing to the
 channel never blocks, and reading from the channel only returns the
 most recent value, or blocks if there are no new values.  Multiple
 readers are supported with a <code>dupSkipChan</code> operation.
</p><p>A skip channel is a pair of <code><a href="Control-Concurrent-MVar.html#t:MVar">MVar</a></code>s. The first <code><a href="Control-Concurrent-MVar.html#t:MVar">MVar</a></code> contains the
 current value, and a list of semaphores that need to be notified
 when it changes. The second <code><a href="Control-Concurrent-MVar.html#t:MVar">MVar</a></code> is a semaphore for this particular
 reader: it is full if there is a value in the channel that this
 reader has not read yet, and empty otherwise.
</p><pre>
     data SkipChan a = SkipChan (MVar (a, [MVar ()])) (MVar ())

newSkipChan :: IO (SkipChan a)
     newSkipChan = do
         sem &lt;- newEmptyMVar
         main &lt;- newMVar (undefined, [sem])
         return (SkipChan main sem)

putSkipChan :: SkipChan a -&gt; a -&gt; IO ()
     putSkipChan (SkipChan main _) v = do
         (_, sems) &lt;- takeMVar main
         putMVar main (v, [])
         mapM_ (sem -&gt; putMVar sem ()) sems

getSkipChan :: SkipChan a -&gt; IO a
     getSkipChan (SkipChan main sem) = do
         takeMVar sem
         (v, sems) &lt;- takeMVar main
         putMVar main (v, sem:sems)
         return v

dupSkipChan :: SkipChan a -&gt; IO (SkipChan a)
     dupSkipChan (SkipChan main _) = do
         sem &lt;- newEmptyMVar
         (v, sems) &lt;- takeMVar main
         putMVar main (v, sem:sems)
         return (SkipChan main sem)
</pre><p>This example was adapted from the original Concurrent Haskell paper.
 For more examples of <code><a href="Control-Concurrent-MVar.html#t:MVar">MVar</a></code>s being used to build higher-level
 synchronization primitives, see <code><a href="Control-Concurrent.html#t:Chan">Chan</a></code> and
 <code><a href="Control-Concurrent.html#t:QSem">QSem</a></code>.
</p></div></div><div id="synopsis"><p id="control.syn" class="caption expander" onclick="toggleSection('syn')">Synopsis</p><ul id="section.syn" class="hide" onclick="toggleSection('syn')"><li class="src short"><span class="keyword">data</span>  <a href="#t:MVar">MVar</a> a</li><li class="src short"><a href="#v:newEmptyMVar">newEmptyMVar</a> ::  <a href="System-IO.html#t:IO">IO</a> (<a href="Control-Concurrent-MVar.html#t:MVar">MVar</a> a)</li><li class="src short"><a href="#v:newMVar">newMVar</a> ::  a -&gt; <a href="System-IO.html#t:IO">IO</a> (<a href="Control-Concurrent-MVar.html#t:MVar">MVar</a> a)</li><li class="src short"><a href="#v:takeMVar">takeMVar</a> ::  <a href="Control-Concurrent-MVar.html#t:MVar">MVar</a> a -&gt; <a href="System-IO.html#t:IO">IO</a> a</li><li class="src short"><a href="#v:putMVar">putMVar</a> ::  <a href="Control-Concurrent-MVar.html#t:MVar">MVar</a> a -&gt; a -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="../ghc-prim-0.2.0.0/GHC-Tuple.html#t:-40--41-">()</a></li><li class="src short"><a href="#v:readMVar">readMVar</a> ::  <a href="Control-Concurrent-MVar.html#t:MVar">MVar</a> a -&gt; <a href="System-IO.html#t:IO">IO</a> a</li><li class="src short"><a href="#v:swapMVar">swapMVar</a> ::  <a href="Control-Concurrent-MVar.html#t:MVar">MVar</a> a -&gt; a -&gt; <a href="System-IO.html#t:IO">IO</a> a</li><li class="src short"><a href="#v:tryTakeMVar">tryTakeMVar</a> ::  <a href="Control-Concurrent-MVar.html#t:MVar">MVar</a> a -&gt; <a href="System-IO.html#t:IO">IO</a> (<a href="Data-Maybe.html#t:Maybe">Maybe</a> a)</li><li class="src short"><a href="#v:tryPutMVar">tryPutMVar</a> ::  <a href="Control-Concurrent-MVar.html#t:MVar">MVar</a> a -&gt; a -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:isEmptyMVar">isEmptyMVar</a> ::  <a href="Control-Concurrent-MVar.html#t:MVar">MVar</a> a -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:withMVar">withMVar</a> ::  <a href="Control-Concurrent-MVar.html#t:MVar">MVar</a> a -&gt; (a -&gt; <a href="System-IO.html#t:IO">IO</a> b) -&gt; <a href="System-IO.html#t:IO">IO</a> b</li><li class="src short"><a href="#v:modifyMVar_">modifyMVar_</a> ::  <a href="Control-Concurrent-MVar.html#t:MVar">MVar</a> a -&gt; (a -&gt; <a href="System-IO.html#t:IO">IO</a> a) -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="../ghc-prim-0.2.0.0/GHC-Tuple.html#t:-40--41-">()</a></li><li class="src short"><a href="#v:modifyMVar">modifyMVar</a> ::  <a href="Control-Concurrent-MVar.html#t:MVar">MVar</a> a -&gt; (a -&gt; <a href="System-IO.html#t:IO">IO</a> (a, b)) -&gt; <a href="System-IO.html#t:IO">IO</a> b</li><li class="src short"><a href="#v:addMVarFinalizer">addMVarFinalizer</a> ::  <a href="Control-Concurrent-MVar.html#t:MVar">MVar</a> a -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="../ghc-prim-0.2.0.0/GHC-Tuple.html#t:-40--41-">()</a> -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="../ghc-prim-0.2.0.0/GHC-Tuple.html#t:-40--41-">()</a></li></ul></div><div id="interface"><h1 id="g:1"><code>MVar</code>s
</h1><div class="top"><p class="src"><span class="keyword">data</span>  <a name="t:MVar" class="def">MVar</a> a </p><div class="doc"><p>An <code><a href="Control-Concurrent-MVar.html#t:MVar">MVar</a></code> (pronounced &quot;em-var&quot;) is a synchronising variable, used
for communication between concurrent threads.  It can be thought of
as a a box, which may be empty or full.
</p></div><div class="subs instances"><p id="control.i:MVar" class="caption collapser" onclick="toggleSection('i:MVar')">Instances</p><div id="section.i:MVar" class="show"><table><tr><td class="src"><a href="Data-Typeable-Internal.html#t:Typeable1">Typeable1</a> <a href="Control-Concurrent-MVar.html#t:MVar">MVar</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Data-Eq.html#t:Eq">Eq</a> (<a href="Control-Concurrent-MVar.html#t:MVar">MVar</a> a)</td><td class="doc empty">&nbsp;</td></tr></table></div></div></div><div class="top"><p class="src"><a name="v:newEmptyMVar" class="def">newEmptyMVar</a> ::  <a href="System-IO.html#t:IO">IO</a> (<a href="Control-Concurrent-MVar.html#t:MVar">MVar</a> a)</p><div class="doc"><p>Create an <code><a href="Control-Concurrent-MVar.html#t:MVar">MVar</a></code> which is initially empty.
</p></div></div><div class="top"><p class="src"><a name="v:newMVar" class="def">newMVar</a> ::  a -&gt; <a href="System-IO.html#t:IO">IO</a> (<a href="Control-Concurrent-MVar.html#t:MVar">MVar</a> a)</p><div class="doc"><p>Create an <code><a href="Control-Concurrent-MVar.html#t:MVar">MVar</a></code> which contains the supplied value.
</p></div></div><div class="top"><p class="src"><a name="v:takeMVar" class="def">takeMVar</a> ::  <a href="Control-Concurrent-MVar.html#t:MVar">MVar</a> a -&gt; <a href="System-IO.html#t:IO">IO</a> a</p><div class="doc"><p>Return the contents of the <code><a href="Control-Concurrent-MVar.html#t:MVar">MVar</a></code>.  If the <code><a href="Control-Concurrent-MVar.html#t:MVar">MVar</a></code> is currently
 empty, <code><a href="Control-Concurrent-MVar.html#v:takeMVar">takeMVar</a></code> will wait until it is full.  After a <code><a href="Control-Concurrent-MVar.html#v:takeMVar">takeMVar</a></code>,
 the <code><a href="Control-Concurrent-MVar.html#t:MVar">MVar</a></code> is left empty.
</p><p>There are two further important properties of <code><a href="Control-Concurrent-MVar.html#v:takeMVar">takeMVar</a></code>:
</p><ul><li> <code><a href="Control-Concurrent-MVar.html#v:takeMVar">takeMVar</a></code> is single-wakeup.  That is, if there are multiple
     threads blocked in <code><a href="Control-Concurrent-MVar.html#v:takeMVar">takeMVar</a></code>, and the <code><a href="Control-Concurrent-MVar.html#t:MVar">MVar</a></code> becomes full,
     only one thread will be woken up.  The runtime guarantees that
     the woken thread completes its <code><a href="Control-Concurrent-MVar.html#v:takeMVar">takeMVar</a></code> operation.
</li><li> When multiple threads are blocked on an <code><a href="Control-Concurrent-MVar.html#t:MVar">MVar</a></code>, they are
     woken up in FIFO order.  This is useful for providing
     fairness properties of abstractions built using <code><a href="Control-Concurrent-MVar.html#t:MVar">MVar</a></code>s.
</li></ul></div></div><div class="top"><p class="src"><a name="v:putMVar" class="def">putMVar</a> ::  <a href="Control-Concurrent-MVar.html#t:MVar">MVar</a> a -&gt; a -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="../ghc-prim-0.2.0.0/GHC-Tuple.html#t:-40--41-">()</a></p><div class="doc"><p>Put a value into an <code><a href="Control-Concurrent-MVar.html#t:MVar">MVar</a></code>.  If the <code><a href="Control-Concurrent-MVar.html#t:MVar">MVar</a></code> is currently full,
 <code><a href="Control-Concurrent-MVar.html#v:putMVar">putMVar</a></code> will wait until it becomes empty.
</p><p>There are two further important properties of <code><a href="Control-Concurrent-MVar.html#v:putMVar">putMVar</a></code>:
</p><ul><li> <code><a href="Control-Concurrent-MVar.html#v:putMVar">putMVar</a></code> is single-wakeup.  That is, if there are multiple
     threads blocked in <code><a href="Control-Concurrent-MVar.html#v:putMVar">putMVar</a></code>, and the <code><a href="Control-Concurrent-MVar.html#t:MVar">MVar</a></code> becomes empty,
     only one thread will be woken up.  The runtime guarantees that
     the woken thread completes its <code><a href="Control-Concurrent-MVar.html#v:putMVar">putMVar</a></code> operation.
</li><li> When multiple threads are blocked on an <code><a href="Control-Concurrent-MVar.html#t:MVar">MVar</a></code>, they are
     woken up in FIFO order.  This is useful for providing
     fairness properties of abstractions built using <code><a href="Control-Concurrent-MVar.html#t:MVar">MVar</a></code>s.
</li></ul></div></div><div class="top"><p class="src"><a name="v:readMVar" class="def">readMVar</a> ::  <a href="Control-Concurrent-MVar.html#t:MVar">MVar</a> a -&gt; <a href="System-IO.html#t:IO">IO</a> a</p><div class="doc"><p>This is a combination of <code><a href="Control-Concurrent-MVar.html#v:takeMVar">takeMVar</a></code> and <code><a href="Control-Concurrent-MVar.html#v:putMVar">putMVar</a></code>; ie. it takes the value
  from the <code><a href="Control-Concurrent-MVar.html#t:MVar">MVar</a></code>, puts it back, and also returns it.  This function
  is atomic only if there are no other producers (i.e. threads calling
  <code><a href="Control-Concurrent-MVar.html#v:putMVar">putMVar</a></code>) for this <code><a href="Control-Concurrent-MVar.html#t:MVar">MVar</a></code>.
</p></div></div><div class="top"><p class="src"><a name="v:swapMVar" class="def">swapMVar</a> ::  <a href="Control-Concurrent-MVar.html#t:MVar">MVar</a> a -&gt; a -&gt; <a href="System-IO.html#t:IO">IO</a> a</p><div class="doc"><p>Take a value from an <code><a href="Control-Concurrent-MVar.html#t:MVar">MVar</a></code>, put a new value into the <code><a href="Control-Concurrent-MVar.html#t:MVar">MVar</a></code> and
  return the value taken. This function is atomic only if there are
  no other producers for this <code><a href="Control-Concurrent-MVar.html#t:MVar">MVar</a></code>.
</p></div></div><div class="top"><p class="src"><a name="v:tryTakeMVar" class="def">tryTakeMVar</a> ::  <a href="Control-Concurrent-MVar.html#t:MVar">MVar</a> a -&gt; <a href="System-IO.html#t:IO">IO</a> (<a href="Data-Maybe.html#t:Maybe">Maybe</a> a)</p><div class="doc"><p>A non-blocking version of <code><a href="Control-Concurrent-MVar.html#v:takeMVar">takeMVar</a></code>.  The <code><a href="Control-Concurrent-MVar.html#v:tryTakeMVar">tryTakeMVar</a></code> function
 returns immediately, with <code><a href="Data-Maybe.html#v:Nothing">Nothing</a></code> if the <code><a href="Control-Concurrent-MVar.html#t:MVar">MVar</a></code> was empty, or
 <code><code><a href="Data-Maybe.html#v:Just">Just</a></code> a</code> if the <code><a href="Control-Concurrent-MVar.html#t:MVar">MVar</a></code> was full with contents <code>a</code>.  After <code><a href="Control-Concurrent-MVar.html#v:tryTakeMVar">tryTakeMVar</a></code>,
 the <code><a href="Control-Concurrent-MVar.html#t:MVar">MVar</a></code> is left empty.
</p></div></div><div class="top"><p class="src"><a name="v:tryPutMVar" class="def">tryPutMVar</a> ::  <a href="Control-Concurrent-MVar.html#t:MVar">MVar</a> a -&gt; a -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="Data-Bool.html#t:Bool">Bool</a></p><div class="doc"><p>A non-blocking version of <code><a href="Control-Concurrent-MVar.html#v:putMVar">putMVar</a></code>.  The <code><a href="Control-Concurrent-MVar.html#v:tryPutMVar">tryPutMVar</a></code> function
 attempts to put the value <code>a</code> into the <code><a href="Control-Concurrent-MVar.html#t:MVar">MVar</a></code>, returning <code><a href="Data-Bool.html#v:True">True</a></code> if
 it was successful, or <code><a href="Data-Bool.html#v:False">False</a></code> otherwise.
</p></div></div><div class="top"><p class="src"><a name="v:isEmptyMVar" class="def">isEmptyMVar</a> ::  <a href="Control-Concurrent-MVar.html#t:MVar">MVar</a> a -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="Data-Bool.html#t:Bool">Bool</a></p><div class="doc"><p>Check whether a given <code><a href="Control-Concurrent-MVar.html#t:MVar">MVar</a></code> is empty.
</p><p>Notice that the boolean value returned  is just a snapshot of
 the state of the MVar. By the time you get to react on its result,
 the MVar may have been filled (or emptied) - so be extremely
 careful when using this operation.   Use <code><a href="Control-Concurrent-MVar.html#v:tryTakeMVar">tryTakeMVar</a></code> instead if possible.
</p></div></div><div class="top"><p class="src"><a name="v:withMVar" class="def">withMVar</a> ::  <a href="Control-Concurrent-MVar.html#t:MVar">MVar</a> a -&gt; (a -&gt; <a href="System-IO.html#t:IO">IO</a> b) -&gt; <a href="System-IO.html#t:IO">IO</a> b</p><div class="doc"><p><code><a href="Control-Concurrent-MVar.html#v:withMVar">withMVar</a></code> is an exception-safe wrapper for operating on the contents
  of an <code><a href="Control-Concurrent-MVar.html#t:MVar">MVar</a></code>.  This operation is exception-safe: it will replace the
  original contents of the <code><a href="Control-Concurrent-MVar.html#t:MVar">MVar</a></code> if an exception is raised (see
  <a href="Control-Exception.html">Control.Exception</a>).  However, it is only atomic if there are no
  other producers for this <code><a href="Control-Concurrent-MVar.html#t:MVar">MVar</a></code>.
</p></div></div><div class="top"><p class="src"><a name="v:modifyMVar_" class="def">modifyMVar_</a> ::  <a href="Control-Concurrent-MVar.html#t:MVar">MVar</a> a -&gt; (a -&gt; <a href="System-IO.html#t:IO">IO</a> a) -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="../ghc-prim-0.2.0.0/GHC-Tuple.html#t:-40--41-">()</a></p><div class="doc"><p>An exception-safe wrapper for modifying the contents of an <code><a href="Control-Concurrent-MVar.html#t:MVar">MVar</a></code>.
  Like <code><a href="Control-Concurrent-MVar.html#v:withMVar">withMVar</a></code>, <code><a href="Control-Concurrent-MVar.html#v:modifyMVar">modifyMVar</a></code> will replace the original contents of
  the <code><a href="Control-Concurrent-MVar.html#t:MVar">MVar</a></code> if an exception is raised during the operation.  This
  function is only atomic if there are no other producers for this
  <code><a href="Control-Concurrent-MVar.html#t:MVar">MVar</a></code>.
</p></div></div><div class="top"><p class="src"><a name="v:modifyMVar" class="def">modifyMVar</a> ::  <a href="Control-Concurrent-MVar.html#t:MVar">MVar</a> a -&gt; (a -&gt; <a href="System-IO.html#t:IO">IO</a> (a, b)) -&gt; <a href="System-IO.html#t:IO">IO</a> b</p><div class="doc"><p>A slight variation on <code><a href="Control-Concurrent-MVar.html#v:modifyMVar_">modifyMVar_</a></code> that allows a value to be
  returned (<code>b</code>) in addition to the modified value of the <code><a href="Control-Concurrent-MVar.html#t:MVar">MVar</a></code>.
</p></div></div><div class="top"><p class="src"><a name="v:addMVarFinalizer" class="def">addMVarFinalizer</a> ::  <a href="Control-Concurrent-MVar.html#t:MVar">MVar</a> a -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="../ghc-prim-0.2.0.0/GHC-Tuple.html#t:-40--41-">()</a> -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="../ghc-prim-0.2.0.0/GHC-Tuple.html#t:-40--41-">()</a></p><div class="doc"><p>Add a finalizer to an <code><a href="Control-Concurrent-MVar.html#t:MVar">MVar</a></code> (GHC only).  See <a href="Foreign-ForeignPtr.html">Foreign.ForeignPtr</a> and
 <a href="System-Mem-Weak.html">System.Mem.Weak</a> for more about finalizers.
</p></div></div></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.11.0</p></div></body></html>