Copyright (c) Tim Watson 2012 - 2017 BSD3 (see the file LICENSE) Tim Watson experimental non-portable (requires concurrency) None Haskell98

Control.Distributed.Process.Extras.Timer

Description

Provides an API for running code or sending messages, either after some initial delay or periodically, and for cancelling, re-setting and/or flushing pending timers.

Synopsis

# Documentation

an opaque reference to a timer

data Tick Source #

represents a tick event that timers can generate

Constructors

 Tick

Instances

 Source # Methods(==) :: Tick -> Tick -> Bool #(/=) :: Tick -> Tick -> Bool # Source # MethodsshowsPrec :: Int -> Tick -> ShowS #show :: Tick -> String #showList :: [Tick] -> ShowS # Source # Associated Typestype Rep Tick :: * -> * # Methodsfrom :: Tick -> Rep Tick x #to :: Rep Tick x -> Tick # Source # Methodsput :: Tick -> Put #putList :: [Tick] -> Put # Source # Methodsrnf :: Tick -> () # type Rep Tick Source # type Rep Tick = D1 * (MetaData "Tick" "Control.Distributed.Process.Extras.Timer" "distributed-process-extras-0.3.5-7qzKH0dWmcLBNm6JMkdrjz" False) (C1 * (MetaCons "Tick" PrefixI False) (U1 *))

blocks the calling Process for the specified TimeInterval. Note that this function assumes that a blocking receive is the most efficient approach to acheiving this, however the runtime semantics (particularly with regards scheduling) should not differ from threadDelay in practise.

Literate way of saying sleepFor 3 Seconds.

starts a timer which sends the supplied message to the destination process after the specified time interval.

runs the supplied process action(s) after t has elapsed

calls exit pid reason after t has elapsed

kills the specified process after t has elapsed

starts a timer that repeatedly sends the supplied message to the destination process each time the specified time interval elapses. To stop messages from being sent in future, cancelTimer can be called.

sets up a timer that sends Tick repeatedly at intervals of t

runs the supplied process action(s) repeatedly at intervals of t

resets a running timer. Note: Cancelling a timer does not guarantee that all its messages are prevented from being delivered to the target process. Also note that resetting an ongoing timer (started using the startTimer or periodically functions) will only cause the current elapsed period to time out, after which the timer will continue running. To stop a long-running timer permanently, you should use cancelTimer instead.

permanently cancels a timer

flushTimer :: (Serializable a, Eq a) => TimerRef -> a -> Delay -> Process () Source #

cancels a running timer and flushes any viable timer messages from the process' message queue. This function should only be called by the process expecting to receive the timer's messages!