flag <- getTimeoutFlag $ 5*24*60 * 60 -- wait exactly 5 days. even
-- if the program restart
ap <- step . atomically $ readSomewhere >> return False
`orElse` waitUntilSTM flag >> return True
case ap of
False -> print "something received"
True -> print "timeout"
-- restarts in case of failure
ap <- atomically $ readSomewhere >> return False
`orElse` waitUntilSTM flag >> return True
case ap of
False -> print "something received"
True -> print "timeout"
------
transientTimeout t= do
flag <- atomically $ newTVar False
forkIO $ threadDelay(t * 1000000) >> atomically (writeTVar flag True)
>> myThreadId >>= killThread
return flag
2010/10/14 Michael Snoyman <
michael@snoyman.com>:
> Hey all,
>
> Is there a library that supports fuzzy time deltas? For example, given
> two UTCTimes (or something like that) it could produce:
>
> 43 seconds
> 13 minutes
> 17 hours
> 4 days
> 8 months
>
> I want to use it for the news feature on Haskellers. It's not that
> hard to write, just wondering if it's already been done.
>
> Michael
> _______________________________________________
> Haskell-Cafe mailing list
>
Haskell-Cafe@haskell.org>
http://www.haskell.org/mailman/listinfo/haskell-cafe
>