[Haskell-cafe] Shared/Exclusive Locks

John Goerzen jgoerzen at complete.org
Wed Dec 28 11:05:15 EST 2005


Hello,

I have the need for a locking object that can provide shared and
exclusive locks in much the same manner as the POSIX flock() function.

A thread that acquires an exclusive lock has a guarantee that no other
thread holds any locks.

A thread that acquires a shared lock has a guarantee that no other
thread holds an exclusive lock, though any number of other threads hold
shared locks.

My intuition tells me that this could be implemented in terms of an MVar
somehow.  (At least, I've used MVars for simple locks for quite some
time.)  But I can't quite figure out how.  Any ideas?

Thanks,

-- John



More information about the Haskell-Cafe mailing list