distributed-process-extras-0.1.1: Cloud Haskell Extras

Copyright(c) Tim Watson, Jeff Epstein, Alan Zimmerman
LicenseBSD3 (see the file LICENSE)
MaintainerTim Watson
Stabilityexperimental
Portabilitynon-portable (requires concurrency)
Safe HaskellNone
LanguageHaskell98

Control.Distributed.Process.Extras.Time

Contents

Description

This module provides facilities for working with time delays and timeouts. The type Timeout and the timeout family of functions provide mechanisms for working with threadDelay-like behaviour that operates on microsecond values.

The TimeInterval and TimeUnit related functions provide an abstraction for working with various time intervals, whilst the Delay type provides a corrolary to timeout that works with these.

Synopsis

Time interval handling

microSeconds :: Int -> TimeInterval Source

given a number, produces a TimeInterval of microseconds

milliSeconds :: Int -> TimeInterval Source

given a number, produces a TimeInterval of milliseconds

seconds :: Int -> TimeInterval Source

given a number, produces a TimeInterval of seconds

minutes :: Int -> TimeInterval Source

given a number, produces a TimeInterval of minutes

hours :: Int -> TimeInterval Source

given a number, produces a TimeInterval of hours

asTimeout :: TimeInterval -> Int Source

converts the supplied TimeInterval to microseconds

after :: Int -> TimeUnit -> Int Source

Convenience for making timeouts; e.g.,

receiveTimeout (after 3 Seconds) [ match (\"ok" -> return ()) ]

within :: Int -> TimeUnit -> TimeInterval Source

Convenience for making TimeInterval; e.g.,

let ti = within 5 Seconds in .....

timeToMicros :: TimeUnit -> Int -> Int Source

converts the supplied TimeUnit to microseconds

data TimeInterval Source

A time interval.

data TimeUnit Source

Defines the time unit for a Timeout value

Constructors

Days 
Hours 
Minutes 
Seconds 
Millis 
Micros 

data Delay Source

Represents either a delay of TimeInterval, an infinite wait or no delay (i.e., non-blocking).

Instances

Eq Delay 
Num Delay

Allow (+) and (-) operations on Delays

Show Delay 
Generic Delay 
Binary Delay 
NFData Delay 
Typeable * Delay 
type Rep Delay 

Conversion To/From NominalDiffTime

timeIntervalToDiffTime :: TimeInterval -> NominalDiffTime Source

given a TimeInterval, provide an equivalent NominalDiffTim

diffTimeToTimeInterval :: NominalDiffTime -> TimeInterval Source

given a NominalDiffTim, provide an equivalent TimeInterval@

diffTimeToDelay :: NominalDiffTime -> Delay Source

given a NominalDiffTim, provide an equivalent Delay@

delayToDiffTime :: Delay -> NominalDiffTime Source

given a Delay, provide an equivalent NominalDiffTim

microsecondsToNominalDiffTime :: Integer -> NominalDiffTime Source

Create a NominalDiffTime from a number of microseconds.

(Legacy) Timeout Handling

type Timeout = Maybe Int Source

Represents a timeout in terms of microseconds, where Nothing stands for infinity and Just 0, no-delay.

data TimeoutNotification Source

Send to a process when a timeout expires.

Constructors

TimeoutNotification Tag 

timeout :: Int -> Tag -> ProcessId -> Process () Source

Sends the calling process TimeoutNotification tag after time microseconds

infiniteWait :: Timeout Source

Constructs an inifinite Timeout.

noWait :: Timeout Source

Constructs a no-wait Timeout