Timers (was Re: [Haskell-cafe] Optimizing a high-traffic network architecture)

Tomasz Zielonka tomasz.zielonka at gmail.com
Thu Dec 15 06:08:16 EST 2005

On Thu, Dec 15, 2005 at 10:46:55AM +0000, Joel Reymont wrote:
> One idea would be to index the timer on ThreadId and name and stick  
> Nothing into the timer action once the timer has been fired/stopped.  
> Since timers are restarted with the same name quite often this would  
> just keep one relatively big map in memory. The additional ThreadId  
> would help distinguish the timers and avoid clashes.

I don't know how you use your timers, but perhaps startTimer could
return a cancel action? It's type would be

    startTimer :: Int -> (IO ()) -> IO (IO ())

and you would use it like this

    cancel <- startTimer delay action



How cancelling was implemented would be entirely startTimer's business.

Best regards

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