[Haskell-cafe] How to use QSem?

S. Alexander Jacobson haskell at alexjacobson.com
Tue Jun 22 16:43:34 EDT 2004

The GHC documentation on QSem is very sparse.  I
would like to give a thread exclusive access to a

My *guess* based on the documentation is that I
can create an exclusive lock using:

   logSem <- newQSem 1

And then any thread that wants to lock the
resource uses:

   withLogSem x = do waitQSem logSem; y <- x; signalQSem logSem; return y

as follows:

   withLogSem $ rotate curLogPos

Am I misunderstanding QSem?


S. Alexander Jacobson                  mailto:me at alexjacobson.com
tel:917-770-6565                       http://alexjacobson.com

More information about the Haskell-Cafe mailing list