[Haskell-cafe] Number of outstanding messages in Chan or TChan

Tomasz Zielonka tomasz.zielonka at gmail.com
Tue Dec 6 05:00:48 EST 2005


On Tue, Dec 06, 2005 at 09:54:57AM +0000, Joel Reymont wrote:
> Is there a way to check the number of outstanding messages in a Chan  
> or TChan?
> 
> I suspect my problem is related to not reading messages fast enough  
> and I'd like to troubleshoot this by scanning my channels once every  
> few seconds and dumping statistics.

I would create a new ADT consisting of a TChan and TVar Int, increased
on writeTChan and decreased on readTChan.

Indeed, not reading messages fast enough can cause something similar
to space leak. Perhaps use a bounded TChan, it should be quite easy
to do in STM.

Best regards
Tomasz

-- 
I am searching for a programmer who is good at least in some of
[Haskell, ML, C++, Linux, FreeBSD, math] for work in Warsaw, Poland


More information about the Haskell-Cafe mailing list