Sophie

Sophie

distrib > Fedora > 18 > i386 > by-pkgid > e903bc4610bdd8e3af0e21c20ed8f4f0 > files > 37

ghc-SafeSemaphore-devel-0.9.0-1.fc18.i686.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.SSem</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-SSem.html");};
//]]>
</script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="src/Control-Concurrent-SSem.html">Source</a></li><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">SafeSemaphore-0.9.0: Much safer replacement for QSemN, QSem, and SampleVar</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>haskell@list.mightyreason.com</td></tr><tr><th>Safe Haskell</th><td>Safe-Infered</td></tr></table><p class="caption">Control.Concurrent.SSem</p></div><div id="description"><p class="caption">Description</p><div class="doc"><p>Very simple quantity semaphore.
</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:SSem">SSem</a> </li><li class="src short"><a href="#v:new">new</a> :: <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Int.html#t:Int">Int</a> -&gt; <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/System-IO.html#t:IO">IO</a> <a href="Control-Concurrent-SSem.html#t:SSem">SSem</a></li><li class="src short"><a href="#v:withSem">withSem</a> ::  <a href="Control-Concurrent-SSem.html#t:SSem">SSem</a> -&gt; <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/System-IO.html#t:IO">IO</a> a -&gt; <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/System-IO.html#t:IO">IO</a> a</li><li class="src short"><a href="#v:wait">wait</a> :: <a href="Control-Concurrent-SSem.html#t:SSem">SSem</a> -&gt; <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/System-IO.html#t:IO">IO</a> <a href="/usr/share/doc/ghc/html/libraries/ghc-prim-0.2.0.0/GHC-Tuple.html#t:-40--41-">()</a></li><li class="src short"><a href="#v:signal">signal</a> :: <a href="Control-Concurrent-SSem.html#t:SSem">SSem</a> -&gt; <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/System-IO.html#t:IO">IO</a> <a href="/usr/share/doc/ghc/html/libraries/ghc-prim-0.2.0.0/GHC-Tuple.html#t:-40--41-">()</a></li><li class="src short"><a href="#v:tryWait">tryWait</a> :: <a href="Control-Concurrent-SSem.html#t:SSem">SSem</a> -&gt; <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/System-IO.html#t:IO">IO</a> (<a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Maybe.html#t:Maybe">Maybe</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Int.html#t:Int">Int</a>)</li><li class="src short"><a href="#v:withSemN">withSemN</a> ::  <a href="Control-Concurrent-SSem.html#t:SSem">SSem</a> -&gt; <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Int.html#t:Int">Int</a> -&gt; <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/System-IO.html#t:IO">IO</a> a -&gt; <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/System-IO.html#t:IO">IO</a> a</li><li class="src short"><a href="#v:waitN">waitN</a> :: <a href="Control-Concurrent-SSem.html#t:SSem">SSem</a> -&gt; <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Int.html#t:Int">Int</a> -&gt; <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/System-IO.html#t:IO">IO</a> <a href="/usr/share/doc/ghc/html/libraries/ghc-prim-0.2.0.0/GHC-Tuple.html#t:-40--41-">()</a></li><li class="src short"><a href="#v:signalN">signalN</a> :: <a href="Control-Concurrent-SSem.html#t:SSem">SSem</a> -&gt; <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Int.html#t:Int">Int</a> -&gt; <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/System-IO.html#t:IO">IO</a> <a href="/usr/share/doc/ghc/html/libraries/ghc-prim-0.2.0.0/GHC-Tuple.html#t:-40--41-">()</a></li><li class="src short"><a href="#v:tryWaitN">tryWaitN</a> :: <a href="Control-Concurrent-SSem.html#t:SSem">SSem</a> -&gt; <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Int.html#t:Int">Int</a> -&gt; <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/System-IO.html#t:IO">IO</a> (<a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Maybe.html#t:Maybe">Maybe</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Int.html#t:Int">Int</a>)</li><li class="src short"><a href="#v:getValue">getValue</a> :: <a href="Control-Concurrent-SSem.html#t:SSem">SSem</a> -&gt; <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/System-IO.html#t:IO">IO</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Int.html#t:Int">Int</a></li></ul></div><div id="interface"><h1>Documentation</h1><div class="top"><p class="src"><span class="keyword">data</span>  <a name="t:SSem" class="def">SSem</a>  <a href="src/Control-Concurrent-STM-SSemInternals.html#SSem" class="link">Source</a></p><div class="subs instances"><p id="control.i:SSem" class="caption collapser" onclick="toggleSection('i:SSem')">Instances</p><div id="section.i:SSem" class="show"><table><tr><td class="src"><a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Eq.html#t:Eq">Eq</a> <a href="Control-Concurrent-SSem.html#t:SSem">SSem</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Typeable-Internal.html#t:Typeable">Typeable</a> <a href="Control-Concurrent-SSem.html#t:SSem">SSem</a></td><td class="doc empty">&nbsp;</td></tr></table></div></div></div><div class="top"><p class="src"><a name="v:new" class="def">new</a> :: <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Int.html#t:Int">Int</a> -&gt; <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/System-IO.html#t:IO">IO</a> <a href="Control-Concurrent-SSem.html#t:SSem">SSem</a><a href="src/Control-Concurrent-SSem.html#new" class="link">Source</a></p><div class="doc"><p>Create a new semaphore with the given argument as the initially available quantity.  This
 allows new semaphores to start with a negative, zero, or positive quantity.
</p></div></div><div class="top"><p class="src"><a name="v:withSem" class="def">withSem</a> ::  <a href="Control-Concurrent-SSem.html#t:SSem">SSem</a> -&gt; <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/System-IO.html#t:IO">IO</a> a -&gt; <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/System-IO.html#t:IO">IO</a> a<a href="src/Control-Concurrent-SSem.html#withSem" class="link">Source</a></p><div class="doc"><p>It is recommended that all paired uses of <code><a href="Control-Concurrent-SSem.html#v:wait">wait</a></code> and <code><a href="Control-Concurrent-SSem.html#v:signal">signal</a></code> use the <code>with</code> bracketed form
 to ensure exceptions safety.
</p></div></div><div class="top"><p class="src"><a name="v:wait" class="def">wait</a> :: <a href="Control-Concurrent-SSem.html#t:SSem">SSem</a> -&gt; <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/System-IO.html#t:IO">IO</a> <a href="/usr/share/doc/ghc/html/libraries/ghc-prim-0.2.0.0/GHC-Tuple.html#t:-40--41-">()</a><a href="src/Control-Concurrent-SSem.html#wait" class="link">Source</a></p><div class="doc"><p>Try to take a unit of value from the semaphore.  This succeeds when the current quantity is
 positive, and then reduces the quantity by one.  Otherwise this will block and <code>retry</code> until it
 succeeds or is killed.  This will never result in a negative quantity.  If several threads are
 retying then which one succeeds next is undefined -- an unlucky thread might starve.
</p></div></div><div class="top"><p class="src"><a name="v:signal" class="def">signal</a> :: <a href="Control-Concurrent-SSem.html#t:SSem">SSem</a> -&gt; <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/System-IO.html#t:IO">IO</a> <a href="/usr/share/doc/ghc/html/libraries/ghc-prim-0.2.0.0/GHC-Tuple.html#t:-40--41-">()</a><a href="src/Control-Concurrent-SSem.html#signal" class="link">Source</a></p><div class="doc"><p>Signal that single unit of the semaphore is available.  This increases the available quantity
 by one.
</p></div></div><div class="top"><p class="src"><a name="v:tryWait" class="def">tryWait</a> :: <a href="Control-Concurrent-SSem.html#t:SSem">SSem</a> -&gt; <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/System-IO.html#t:IO">IO</a> (<a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Maybe.html#t:Maybe">Maybe</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Int.html#t:Int">Int</a>)<a href="src/Control-Concurrent-SSem.html#tryWait" class="link">Source</a></p><div class="doc"><p>Non-waiting version of wait.  `tryWait s` is defined as `tryWaitN s 1`
</p></div></div><div class="top"><p class="src"><a name="v:withSemN" class="def">withSemN</a> ::  <a href="Control-Concurrent-SSem.html#t:SSem">SSem</a> -&gt; <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Int.html#t:Int">Int</a> -&gt; <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/System-IO.html#t:IO">IO</a> a -&gt; <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/System-IO.html#t:IO">IO</a> a<a href="src/Control-Concurrent-SSem.html#withSemN" class="link">Source</a></p><div class="doc"><p>It is recommended that all paired uses of <code><a href="Control-Concurrent-SSem.html#v:waitN">waitN</a></code> and <code><a href="Control-Concurrent-SSem.html#v:signalN">signalN</a></code> use the <code>withN</code>
 bracketed form to ensure exceptions safety.
</p></div></div><div class="top"><p class="src"><a name="v:waitN" class="def">waitN</a> :: <a href="Control-Concurrent-SSem.html#t:SSem">SSem</a> -&gt; <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Int.html#t:Int">Int</a> -&gt; <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/System-IO.html#t:IO">IO</a> <a href="/usr/share/doc/ghc/html/libraries/ghc-prim-0.2.0.0/GHC-Tuple.html#t:-40--41-">()</a><a href="src/Control-Concurrent-SSem.html#waitN" class="link">Source</a></p><div class="doc"><p>Try to take the given value from the semaphore.  This succeeds when the quantity is greater or
 equal to the given value, and then subtracts the given value from the quantity.  Otherwise this
 will block and <code>retry</code> until it succeeds or is killed.  This will never result in a negative
 quantity.  If several threads are retrying then which one succeeds next is undefined -- an
 unlucky thread might starve.
</p></div></div><div class="top"><p class="src"><a name="v:signalN" class="def">signalN</a> :: <a href="Control-Concurrent-SSem.html#t:SSem">SSem</a> -&gt; <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Int.html#t:Int">Int</a> -&gt; <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/System-IO.html#t:IO">IO</a> <a href="/usr/share/doc/ghc/html/libraries/ghc-prim-0.2.0.0/GHC-Tuple.html#t:-40--41-">()</a><a href="src/Control-Concurrent-SSem.html#signalN" class="link">Source</a></p><div class="doc"><p>Signal that many units of the semaphore are available.  This changes the available quantity by
 adding the passed size.
</p></div></div><div class="top"><p class="src"><a name="v:tryWaitN" class="def">tryWaitN</a> :: <a href="Control-Concurrent-SSem.html#t:SSem">SSem</a> -&gt; <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Int.html#t:Int">Int</a> -&gt; <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/System-IO.html#t:IO">IO</a> (<a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Maybe.html#t:Maybe">Maybe</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Int.html#t:Int">Int</a>)<a href="src/Control-Concurrent-SSem.html#tryWaitN" class="link">Source</a></p><div class="doc"><p>Non-waiting version of waitN.  It either takes the quantity from the semaphore like
 waitN and returns `Just value taken` or finds insufficient quantity to take and returns
 Nothing
</p></div></div><div class="top"><p class="src"><a name="v:getValue" class="def">getValue</a> :: <a href="Control-Concurrent-SSem.html#t:SSem">SSem</a> -&gt; <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/System-IO.html#t:IO">IO</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Int.html#t:Int">Int</a><a href="src/Control-Concurrent-SSem.html#getValue" class="link">Source</a></p><div class="doc"><p>This returns the current quantity in the semaphore.  This is diffucult to use due to race conditions.
</p></div></div></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.10.0</p></div></body></html>