Re: tryTakeMVar :: MVar a - IO (Maybe a)

2000-04-11 Thread George Russell
Simon Marlow wrote: The only way I can see to do this is to add a lock field to the MVar. And since this lock would look very much like another MVar, you may as well just use another MVar to lock it (after all, that adds exactly zero extra complication to the system :-). Absolutely. There's

Re: tryTakeMVar :: MVar a - IO (Maybe a)

2000-04-10 Thread Marcin 'Qrczak' Kowalczyk
Sun, 9 Apr 2000 13:54:47 -0700, Sigbjorn Finne [EMAIL PROTECTED] pisze: Wouldn't be nice to have such function? Have you tried using Concurrent.isEmptyMVar ? isEmptyMVar is not enough to implement tryTakeMVar (but tryTakeMVar would suffice for isEmptyMVar). Just after checking that it is

Re: tryTakeMVar :: MVar a - IO (Maybe a)

2000-04-10 Thread George Russell
Would it be possible to implement an operation to lock an MVar without any extra expense? So that the thread owning the MVar can do things to it, but no other thread can. If it is possible, I suggest that it be added and it would solve Marcin's problem (isEmptyMVar would then suffice).

tryTakeMVar :: MVar a - IO (Maybe a)

2000-04-08 Thread Marcin 'Qrczak' Kowalczyk
Wouldn't be nice to have such function? I wanted to translate a thread example written in Ruby and realized that it's impossible to write that function using MVar primitives provided; and no module seems to provide an equivalent using another kind of concurrent variable. I had to simulate