
On 16/02/2010 15:51, Roel van Dijk wrote:
Hello,
We wrote a small library (1) which offers a few extra synchronization primitives. These primitives are found in the standard libraries of languages like Java and Python, but not in Haskell.
Before releasing concurrent-extra on hackage, we would like some comments on its name, design, implementation, documentation (2) and general usefulness.
All primitives are implemented with MVars and IORefs, except for Control.Concurrent.STM.Event.
There is a small test suite which tests some properties:
cabal configure -ftest cabal build cabal test
The test suite still needs to be expanded a great deal. We found that testing concurrent algorithms is really hard. Now we test things like "this shouldn't deadlock" by checking if it doesn't take too long. But that doesn't feel very formal. Is there a more principled approach to testing concurrent algorithms in Haskell?
You might want to take a look at the concurrency part of the GHC test suite: http://darcs.haskell.org/testsuite/tests/ghc-regress/concurrent/should_run/ Not that we've really solved the problem you're talking about, but you might get some ideas. Often deadlocks are caught by the RTS and result in an exception which you can catch, though with the threaded RTS this relies on detecting idle time and running the GC, which by default happens after 0.3s of idle time. Some people find this annoying and turn off the idle-time GC (+RTS -I0) but then you lose deadlock detection. Swings and roundabouts. Cheers, Simon