For me, this fixes issue #8. Previously, the Write -> Write state change in acquireWrite was accomplished by the sequence
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 (well, the reader wouldn't even care if the write lock was acquired), 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.
For me, this fixes issue #8. Previously, the
Write
->Write
state change inacquireWrite
was accomplished by the sequenceAs I see it, this is problematic because there is nothing preventing a reader slip in between the
putMVar
and acquiring the write lock (well, the reader wouldn't even care if the write lock was acquired), so I guess thevoid
threw away aRead
state sometimes. There was a similar problem withtryAcquireWrite
, 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.