On 1/23/12 3:19 PM, Edward Z. Yang wrote:
Excerpts from Heka Treep's message of Mon Jan 23 15:11:51 -0500 2012:
actor mbox = do
empty- atomically $ isEmptyTChan mbox
if empty
then actor mbox
else do
val- atomically $ readTChan mbox
Uh, don't you want to combine
On 1/24/12 10:25 AM, Ryan Newton wrote:
This is related but somewhat tangential --
*Why isn't there a tryReadChan?* It looks like it would be implementable
with the current Chan representation in terms of tryTakeMVar. Especially
since isEmptyChan is deprecated this would be nice to have.
On 1/26/12 10:01 PM, wren ng thornton wrote:
On 1/24/12 10:25 AM, Ryan Newton wrote:
This is related but somewhat tangential --
*Why isn't there a tryReadChan?* It looks like it would be implementable
with the current Chan representation in terms of tryTakeMVar. Especially
since isEmptyChan is
On 24/01/2012 15:59, Edward Z. Yang wrote:
Excerpts from Ryan Newton's message of Tue Jan 24 10:25:37 -0500 2012:
This is related but somewhat tangential --
*Why isn't there a tryReadChan?* It looks like it would be implementable
with the current Chan representation in terms of
From: Heka Treep zena.tr...@gmail.com
Subject: Re: Is it true that an exception is always terminates the
thread?
To: Edward Z. Yang ezy...@mit.edu
Cc: glasgow-haskell-users glasgow-haskell-users@haskell.org
Message-ID:
Excerpts from Heka Treep's message of Mon Jan 23 13:56:47 -0500 2012:
adding the message queue (with Chan, MVar or STM) for each process will not
help in this kind of imitation.
Why not? Instead of returning a thread ID, send the write end of a Chan
which the thread is waiting on. You can send
2012/1/23, Edward Z. Yang ezy...@mit.edu:
Excerpts from Heka Treep's message of Mon Jan 23 13:56:47 -0500 2012:
adding the message queue (with Chan, MVar or STM) for each process will
not
help in this kind of imitation.
Why not? Instead of returning a thread ID, send the write end of a Chan
Excerpts from Heka Treep's message of Mon Jan 23 15:11:51 -0500 2012:
import Control.Monad.STM
import Control.Concurrent
import Control.Concurrent.STM.TChan
spawn f = do
mbox - newTChanIO
forkIO $ f mbox
Quoting Heka Treep zena.tr...@gmail.com:
actor mbox = do
empty - atomically $ isEmptyTChan mbox
if empty
then actor mbox
else do
val - atomically $ readTChan mbox
putStrLn val
actor mbox
This looks a bit silly. Why not just this?
actor mbox = forever $
2012/1/23, Edward Z. Yang ezy...@mit.edu:
Excerpts from Heka Treep's message of Mon Jan 23 15:11:51 -0500 2012:
import Control.Monad.STM
import Control.Concurrent
import Control.Concurrent.STM.TChan
spawn f =
Excerpts from Heka Treep's message of Mon Jan 23 16:20:51 -0500 2012:
actor :: TChan String - IO ()
actor mbox = forever $ do
putStrLn call to actor...
msg - atomically $ do
isEmpty - isEmptyTChan mbox
if isEmpty then return Nothing else readTChan mbox = return . Just
when
11 matches
Mail list logo