Remove Control.Parallel*, now in package parallel
[haskell-directory.git] / Control / Concurrent / QSemN.hs
index 8e95903..56c5e50 100644 (file)
@@ -24,11 +24,16 @@ module Control.Concurrent.QSemN
 import Prelude
 
 import Control.Concurrent.MVar
+import Data.Typeable
+
+#include "Typeable.h"
 
 -- |A 'QSemN' is a quantity semaphore, in which the available
 -- \"quantity\" may be signalled or waited for in arbitrary amounts.
 newtype QSemN = QSemN (MVar (Int,[(Int,MVar ())]))
 
+INSTANCE_TYPEABLE0(QSemN,qSemNTc,"QSemN")
+
 -- |Build a new 'QSemN' with a supplied initial quantity.
 newQSemN :: Int -> IO QSemN 
 newQSemN init = do
@@ -42,7 +47,7 @@ waitQSemN (QSemN sem) sz = do
   if (avail - sz) >= 0 then
        -- discharging 'sz' still leaves the semaphore
        -- in an 'unblocked' state.
-     putMVar sem (avail-sz,[])
+     putMVar sem (avail-sz,blocked)
    else do
      block <- newEmptyMVar
      putMVar sem (avail, blocked++[(sz,block)])