[Haskell-cafe] scheduling an alarm

Thomas DuBuisson thomas.dubuisson at gmail.com
Tue Jan 26 13:54:03 EST 2010


Brian Denheyer <briand at aracnet.com> wrote:

> On Mon, 25 Jan 2010 23:19:53 -0800
> Thomas DuBuisson <thomas.dubuisson at gmail.com> wrote:
>
> > 1) Don't use System.Posix.Signals
> > It isn't necessary and makes your code less portable
> >
> > 2) The POSIX SIGALRM is used/caught by the RTS and that is why you are
> > seeing strange behavior.
> >
> > 3) Consider using Haskell exceptions from Control.Concurrent
> > (throwTo). Not sure what you want to do but you can always
> > "myThreadId >>= \tid -> forkIO $ threadDelay someDelayTime >>
> > (throwTo tid someExceptionVal)"
> >
>
> I just want a routine to run every 15 min.
>


You can still use Control.Concurrent:
> import Control.Concurrent
>
> doEvent f usDelay = forkIO $
>   threadDelay usDelay
>   doEvent f usDelay
>   f

Or a wrapper around Control.Concurrent - Ex: The Control-Event package.


> I'm not clear on why the throwTo is in you example.
>

It will give you an exception just like you were expecting from SIGALRM.

Thomas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100126/08bb7aa6/attachment.html


More information about the Haskell-Cafe mailing list