[Haskell-cafe] Broadcast signals between threads

Tomasz Zielonka tomasz.zielonka at gmail.com
Sun May 27 07:36:03 EDT 2007


On Sun, May 27, 2007 at 12:22:54PM +0200, Joachim Breitner wrote:
> Hi,
> 
> Am Samstag, den 26.05.2007, 14:29 +0200 schrieb Tomasz Zielonka:
> > On Fri, May 25, 2007 at 07:57:45PM +0200, Joachim Breitner wrote:
> > > I???m writing a TCP server app ATM. It has one thread per client. Some of
> > > the clients want to be notified if the internal state changes, while
> > > others are happily chatting with the server, possible modifying the
> > > internal state. What I need now is a way for the chatting thread to
> > > signal ???anyone interested??? that the state has changed.
> > 
> > Did you consider using STM for thread synchronisation and communication?
> > STM uses change notifications (or something similar) internally to
> > implement the "retry" operation. I might be just what you need, but more
> > high level.
 
Of course it is not "I" that you might need, but "It" - the STM :-)
Writing "I" instead of "It" is one of the most frequent errors I make
when writing in english - perhaps a sign of egocentrism...?

> No, I haven???t done anything with STM yet. Maybe I???ll look into that.

If your threads just wait until the server state satisfies some
condition, then STM should fit naturally.

Best regards
Tomek


More information about the Haskell-Cafe mailing list