
On Tue, Sep 2, 2014 at 1:01 PM, John Lato
I was thinking you could do away entirely with the Maybe wrapper. But I guess that might not be possible in your case.
Actually, the approach currently on github uses -1 (an invalid descriptor) to represent Nothing, and does away with Maybe altogether, but that's just a implementation detail.
Have you actually observed this behavior? I suspect that the thread will never yield between readMVar and threadWaitRead because there are no allocations. I suppose an async exception could arise, so it might be correct to run that line with exceptions masked.
Not without inserting a superfluous readMVar read between reading the Fd and the threadWaitRead so that a demonstration can precisely control the interleaving of several threads. You are probably correct, that there aren't any yield points between the readMVar and the start of the threadWaitRead call, but are there any potential yield points inside of threadWaitRead itself before the interest in the file descriptor is properly registered in the IO manager? And I agree with Felipe, even if correct, this sort of assumption seems much too strong and fragile to safely make in a library that I hope not to have to maintain too much. As for async exceptions, the binding definitely needs work to make it safe in their presence, but that's another issue entirely. =) Best, Leon