basvandijk/concurrent-extra — pull request #9 by waldheinz (2014-05-31 11:04:21+00:00)
Title: Fix race in ReadWriteLock.(try)acquireWrite, and add a partial test case

For me, this fixes issue #8. Previously, the `Write` -> `Write` state change in `acquireWrite` was accomplished by the sequence

~~~haskell
putMVar state st
Lock.acquire writeLock
void $ swapMVar state Write
~~~

As I see it, this is problematic because there is nothing preventing a reader slip in between the `putMVar` and acquiring the write lock, so I guess the `void` threw away a read state sometimes. There was a similar problem with `tryAcquireWrite`, which should be fixed as well.

I also added a new test case for this, but it's not in a good state currently: The test is recognized as `passed` even when the bug strikes. The only way to know is to have a look at the test's log file. I included it anyway because at least it's no worse than before.