distributed-process-extras-0.3.8: 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
LanguageHaskell2010

Control.Distributed.Process.Extras.Time

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.

Instances

Instances details
Generic TimeInterval Source # 
Instance details

Defined in Control.Distributed.Process.Extras.Time

Associated Types

type Rep TimeInterval 
Instance details

Defined in Control.Distributed.Process.Extras.Time

type Rep TimeInterval = D1 ('MetaData "TimeInterval" "Control.Distributed.Process.Extras.Time" "distributed-process-extras-0.3.8-4huuwGKrrU1D03Xpc2ef8J" 'False) (C1 ('MetaCons "TimeInterval" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 TimeUnit) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int)))
Num TimeInterval Source #

Allow (+) and (-) operations on TimeIntervals

Instance details

Defined in Control.Distributed.Process.Extras.Time

Show TimeInterval Source # 
Instance details

Defined in Control.Distributed.Process.Extras.Time

Binary TimeInterval Source # 
Instance details

Defined in Control.Distributed.Process.Extras.Time

NFData TimeInterval Source # 
Instance details

Defined in Control.Distributed.Process.Extras.Time

Methods

rnf :: TimeInterval -> () #

Eq TimeInterval Source # 
Instance details

Defined in Control.Distributed.Process.Extras.Time

type Rep TimeInterval Source # 
Instance details

Defined in Control.Distributed.Process.Extras.Time

type Rep TimeInterval = D1 ('MetaData "TimeInterval" "Control.Distributed.Process.Extras.Time" "distributed-process-extras-0.3.8-4huuwGKrrU1D03Xpc2ef8J" 'False) (C1 ('MetaCons "TimeInterval" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 TimeUnit) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int)))

data TimeUnit Source #

Defines the time unit for a Timeout value

Constructors

Days 
Hours 
Minutes 
Seconds 
Millis 
Micros 

Instances

Instances details
Generic TimeUnit Source # 
Instance details

Defined in Control.Distributed.Process.Extras.Time

Associated Types

type Rep TimeUnit 
Instance details

Defined in Control.Distributed.Process.Extras.Time

type Rep TimeUnit = D1 ('MetaData "TimeUnit" "Control.Distributed.Process.Extras.Time" "distributed-process-extras-0.3.8-4huuwGKrrU1D03Xpc2ef8J" 'False) ((C1 ('MetaCons "Days" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "Hours" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Minutes" 'PrefixI 'False) (U1 :: Type -> Type))) :+: (C1 ('MetaCons "Seconds" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "Millis" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Micros" 'PrefixI 'False) (U1 :: Type -> Type))))

Methods

from :: TimeUnit -> Rep TimeUnit x #

to :: Rep TimeUnit x -> TimeUnit #

Show TimeUnit Source # 
Instance details

Defined in Control.Distributed.Process.Extras.Time

Binary TimeUnit Source # 
Instance details

Defined in Control.Distributed.Process.Extras.Time

Methods

put :: TimeUnit -> Put #

get :: Get TimeUnit #

putList :: [TimeUnit] -> Put #

NFData TimeUnit Source # 
Instance details

Defined in Control.Distributed.Process.Extras.Time

Methods

rnf :: TimeUnit -> () #

Eq TimeUnit Source # 
Instance details

Defined in Control.Distributed.Process.Extras.Time

type Rep TimeUnit Source # 
Instance details

Defined in Control.Distributed.Process.Extras.Time

type Rep TimeUnit = D1 ('MetaData "TimeUnit" "Control.Distributed.Process.Extras.Time" "distributed-process-extras-0.3.8-4huuwGKrrU1D03Xpc2ef8J" 'False) ((C1 ('MetaCons "Days" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "Hours" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Minutes" 'PrefixI 'False) (U1 :: Type -> Type))) :+: (C1 ('MetaCons "Seconds" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "Millis" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Micros" 'PrefixI 'False) (U1 :: Type -> Type))))

data Delay Source #

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

Instances

Instances details
Generic Delay Source # 
Instance details

Defined in Control.Distributed.Process.Extras.Time

Associated Types

type Rep Delay 
Instance details

Defined in Control.Distributed.Process.Extras.Time

type Rep Delay = D1 ('MetaData "Delay" "Control.Distributed.Process.Extras.Time" "distributed-process-extras-0.3.8-4huuwGKrrU1D03Xpc2ef8J" 'False) (C1 ('MetaCons "Delay" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 TimeInterval)) :+: (C1 ('MetaCons "Infinity" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "NoDelay" 'PrefixI 'False) (U1 :: Type -> Type)))

Methods

from :: Delay -> Rep Delay x #

to :: Rep Delay x -> Delay #

Num Delay Source #

Allow (+) and (-) operations on Delays

Instance details

Defined in Control.Distributed.Process.Extras.Time

Show Delay Source # 
Instance details

Defined in Control.Distributed.Process.Extras.Time

Methods

showsPrec :: Int -> Delay -> ShowS #

show :: Delay -> String #

showList :: [Delay] -> ShowS #

Binary Delay Source # 
Instance details

Defined in Control.Distributed.Process.Extras.Time

Methods

put :: Delay -> Put #

get :: Get Delay #

putList :: [Delay] -> Put #

NFData Delay Source # 
Instance details

Defined in Control.Distributed.Process.Extras.Time

Methods

rnf :: Delay -> () #

Eq Delay Source # 
Instance details

Defined in Control.Distributed.Process.Extras.Time

Methods

(==) :: Delay -> Delay -> Bool #

(/=) :: Delay -> Delay -> Bool #

type Rep Delay Source # 
Instance details

Defined in Control.Distributed.Process.Extras.Time

type Rep Delay = D1 ('MetaData "Delay" "Control.Distributed.Process.Extras.Time" "distributed-process-extras-0.3.8-4huuwGKrrU1D03Xpc2ef8J" 'False) (C1 ('MetaCons "Delay" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 TimeInterval)) :+: (C1 ('MetaCons "Infinity" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "NoDelay" 'PrefixI 'False) (U1 :: Type -> Type)))

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