Hello Joel,

Tuesday, December 06, 2005, 12:54:57 PM, you wrote:

JR> Is there a way to check the number of outstanding messages in a Chan  
JR> or TChan?

either
1) use MVars/TMVars instead of Channels. in any case your logging
thread must consume data not slower than other channels produce then.
in fact, using Chan have meaning only to smooth temporary speed
differences between different threads. are you really need this??

2) i hope that you already replaced passing a Chan to subroutines with
passing an actions that read/write this Chan. in this case you can go
further and add to this actions incrementing/decrementing MVar
counter. but even without tests it's evident that 1000 producer threads
will get 1000 times more attention than 1 consumer thread if you don't
have any restrictions on producing and consuming data. if you
absolutely don't want to use MVars instead of channels, then at least you
can modify these actions so that number of Chan elements will be
limited (use additional "MVar full" which is filled in case of too
large number of elements in channel and emptied by logger thread)



-- 
Best regards,
 Bulat                            mailto:[EMAIL PROTECTED]



_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to