Re: No atomic read on MVar?

2008-11-06 Thread Philip K.F. Hölzenspies
L.S., First off, obviously, many thanks for all these usefull replies. A special thanks to Chris. Your e-mail was very insightfull and instructive. I did, in the end, decide to do my own queuing and scheduling using MVar () signaling, guarding MVar a things. I want to avoid IORefs, because for

Re: No atomic read on MVar?

2008-11-04 Thread Arnar Birgisson
On Mon, Nov 3, 2008 at 23:51, David Menendez [EMAIL PROTECTED] wrote: On Mon, Nov 3, 2008 at 6:29 AM, Philip K.F. Hölzenspies [EMAIL PROTECTED] wrote: I have now implemented my variable as a pair of MVars, one of which serves as a lock on the other. Both for performance reasons and for

Re: No atomic read on MVar?

2008-11-04 Thread Chris Kuklewicz
It is true that STM's TMVars (which are TVar (Maybe _)) allow atomic readTMVar. They are not a great replacement for MVars for serious performance reasons. MVars have wake one semantics: There can be many threads stopped and waiting on a particular MVar to be filled/emptied. These are

Re: No atomic read on MVar?

2008-11-03 Thread Simon Marlow
Philip K.F. Hölzenspies wrote: I ran face first into an assumption I had made on MVar operations (in Control.Concurrent); I had assumed there to be an atomic read (i.e. non-destructive read, as opposed to destructive consume/take). The following program illustrates what I had in mind.

No atomic read on MVar?

2008-11-03 Thread Philip K.F. Hölzenspies
Dear GHCers, I ran face first into an assumption I had made on MVar operations (in Control.Concurrent); I had assumed there to be an atomic read (i.e. non-destructive read, as opposed to destructive consume/take). The following program illustrates what I had in mind. testAtomic :: IO ()

Re: No atomic read on MVar?

2008-11-03 Thread David Menendez
On Mon, Nov 3, 2008 at 6:29 AM, Philip K.F. Hölzenspies [EMAIL PROTECTED] wrote: I have now implemented my variable as a pair of MVars, one of which serves as a lock on the other. Both for performance reasons and for deadlock analysis, I would really like an atomic read on MVars, though. Does