| However, preemptive multitasking operating systems offer support for waiting 
for multiple
| "MVars", until *either* one of them returns (or timeouts).

The standard way to do this is to spawn a thread for each MVar you are waiting 
for; the thread blocks on the MVar and, when it unblocks it fills a third MVar 
with the outcome.  The original thread waits on this single MVar.  See Section 
5 of http://research.microsoft.com/users/simonpj/papers/concurrent-haskell.ps.gz

Alternatively STM supports such multiple waiting directly
http://research.microsoft.com/%7Esimonpj/papers/stm/index.htm#composble

Simon

| -----Original Message-----
| From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Peter
| Verswyvelen
| Sent: 26 November 2008 18:05
| To: [email protected]
| Subject: [Haskell] Wait for *either* MVar to be set
|
| Maybe this is not the correct mailing list to ask this question, but as a 
similar question was
| asked seemingly unanswered by Duncan Coutts in 2002
| (http://markmail.org/message/kftpnulks7mbz2ij), and as this most likely has 
to do with the GHC
| runtime, I might have more luck to get an answer here... Sorry for the spam 
if this is
| inappropriate; please say so and I will resubscribe to the Haskell Cafe 
mailing list, not
| polluting this main list anymore...
|
| So here's my question.
|
| GHC provides MVar for nice lightweight concurrency synchronization.
|
| However, preemptive multitasking operating systems offer support for waiting 
for multiple
| "MVars", until *either* one of them returns (or timeouts).
|
| I see no way of achieving this with GHC's MVar, unless using Conal Elliott's 
unamb package on
| Hackage that emulates this by spawning and killing two threads (which might 
be an expensive
| operation, I'm not sure)
|
| Am I wrong in this? If so, is this something that might be considered as a 
future enhancement
| in the GHC libraries and runtime?
|
| Thanks very much,
| Peter Verswyvelen
| CTO - Anygma
|
|
|
|
| _______________________________________________
| Haskell mailing list
| [email protected]
| http://www.haskell.org/mailman/listinfo/haskell

_______________________________________________
Haskell mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell

Reply via email to