[Haskell-cafe] How to make asynchronous I/O composable and safe?

wren ng thornton wren at freegeek.org
Sat Jan 14 22:48:57 CET 2012


On 1/14/12 6:27 AM, Daniel Waterworth wrote:
> p.s I'd avoid the TChan for networking code as reading from a TChan is
> a busy operation. [1]
>
> [1] http://hackage.haskell.org/packages/archive/stm/2.2.0.1/doc/html/src/Control-Concurrent-STM-TChan.html#readTChan


The `retry`-ness will be rectified whenever the new version of stm is 
pushed out[1], which includes tryReadTChan for one-shot use. Until then, 
you can use the version of tryReadTChan in stm-chans[2] which provides 
the same operation, though less optimized since it's not behind the API 
wall. Once I learn the version number of when the optimized variants 
will be released, the stm-chans version will use CPP to properly select 
between the new version vs the backport, so you can rely on stm-chans to 
provide a compatibility layer for those operations.


[1] http://www.haskell.org/pipermail/cvs-libraries/2011-April/012914.html

[2] 
http://hackage.haskell.org/packages/archive/stm-chans/1.1.0/doc/html/src/Control-Concurrent-STM-TChan-Compat.html

-- 
Live well,
~wren



More information about the Haskell-Cafe mailing list