Tomasz,

I think it's much simpler than that. I just changed the trace function to send Just String down the channel. Whenever I send Nothing (from waitForChildren) the logger just exits. Simple change in two places, no need for MVars.

Did I miss anything? The program became much snappier, btw.

        Joel

On Nov 22, 2005, at 8:53 AM, Tomasz Zielonka wrote:

Regardless, simple is elegant and your Maybe solution is simple.

But it also requires that you restructure your code, doesn't it?
I am not sure we understood each other here.

One way to restructure your code to enable smooth transition to the
(Chan (Maybe String)) idea would be to change the type of "die request"
from (MVar ()) to (IO ()). You could use

    (dieVar, die) <- do
        dieVar <- newEmptyMVar
        return (dieVar, putMVar dieVar ())

where "dieVar" is used on the receiver side, and die is used on the
sender side. Then you could easily use a different notification
mechanism for logger:

    let die = writeChan parent Nothing

--
http://wagerlabs.com/





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

Reply via email to