extensible-effects-concurrent-0.21.1: Message passing concurrency as extensible-effect

Safe HaskellNone
LanguageHaskell2010

Control.Eff.Concurrent.Process.Timer

Description

Functions for timeouts when receiving messages.

NOTE: If you use a single threaded scheduler, these functions will not work as expected. (This is an open TODO)

Since: 0.12.0

Synopsis

Documentation

data Timeout Source #

A number of micro seconds.

Since: 0.12.0

Instances
Enum Timeout Source # 
Instance details

Defined in Control.Eff.Concurrent.Process.Timer

Eq Timeout Source # 
Instance details

Defined in Control.Eff.Concurrent.Process.Timer

Methods

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

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

Integral Timeout Source # 
Instance details

Defined in Control.Eff.Concurrent.Process.Timer

Num Timeout Source # 
Instance details

Defined in Control.Eff.Concurrent.Process.Timer

Ord Timeout Source # 
Instance details

Defined in Control.Eff.Concurrent.Process.Timer

Real Timeout Source # 
Instance details

Defined in Control.Eff.Concurrent.Process.Timer

Show Timeout Source # 
Instance details

Defined in Control.Eff.Concurrent.Process.Timer

NFData Timeout Source # 
Instance details

Defined in Control.Eff.Concurrent.Process.Timer

Methods

rnf :: Timeout -> () #

data TimerReference Source #

The reference to a timer started by startTimer, required to stop a timer via cancelTimer.

Since: 0.12.0

Instances
Enum TimerReference Source # 
Instance details

Defined in Control.Eff.Concurrent.Process.Timer

Eq TimerReference Source # 
Instance details

Defined in Control.Eff.Concurrent.Process.Timer

Integral TimerReference Source # 
Instance details

Defined in Control.Eff.Concurrent.Process.Timer

Num TimerReference Source # 
Instance details

Defined in Control.Eff.Concurrent.Process.Timer

Ord TimerReference Source # 
Instance details

Defined in Control.Eff.Concurrent.Process.Timer

Real TimerReference Source # 
Instance details

Defined in Control.Eff.Concurrent.Process.Timer

Show TimerReference Source # 
Instance details

Defined in Control.Eff.Concurrent.Process.Timer

NFData TimerReference Source # 
Instance details

Defined in Control.Eff.Concurrent.Process.Timer

Methods

rnf :: TimerReference -> () #

sendAfter :: forall r q message. (Lifted IO q, HasCallStack, SetMember Process (Process q) r, Member Interrupts r, Typeable message, NFData message) => ProcessId -> Timeout -> (TimerReference -> message) -> Eff r TimerReference Source #

Send a message to a given process after waiting. The message is created by applying the function parameter to the TimerReference, such that the message can directly refer to the timer.

Since: 0.12.0

startTimer :: forall r q. (Lifted IO q, HasCallStack, SetMember Process (Process q) r, Member Interrupts r) => Timeout -> Eff r TimerReference Source #

Start a new timer, after the time has elapsed, TimerElapsed is sent to calling process. The message also contains the TimerReference returned by this function. Use cancelTimer to cancel the timer. Use selectTimerElapsed to receive the message using receiveSelectedMessage. To receive messages with guarded with a timeout see receiveAfter.

Since: 0.12.0

cancelTimer :: forall r q. (Lifted IO q, HasCallStack, SetMember Process (Process q) r, Member Interrupts r) => TimerReference -> Eff r () Source #

Cancel a timer started with startTimer.

Since: 0.12.0

receiveAfter :: forall a r q. (Lifted IO q, HasCallStack, SetMember Process (Process q) r, Member Interrupts r, Typeable a, NFData a, Show a) => Timeout -> Eff r (Maybe a) Source #

Wait for a message of the given type for the given time. When no message arrives in time, return Nothing. This is based on receiveSelectedAfter.

Since: 0.12.0

receiveSelectedAfter :: forall a r q. (Lifted IO q, HasCallStack, SetMember Process (Process q) r, Member Interrupts r, Show a) => MessageSelector a -> Timeout -> Eff r (Either TimerElapsed a) Source #

Wait for a message of the given type for the given time. When no message arrives in time, return Left TimerElapsed. This is based on selectTimerElapsed and startTimer.

Since: 0.12.0