Safe Haskell | None |
---|---|
Language | Haskell2010 |
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
- data Timeout
- data TimerReference
- data TimerElapsed
- 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
- startTimer :: forall r q. (Lifted IO q, HasCallStack, SetMember Process (Process q) r, Member Interrupts r) => Timeout -> Eff r TimerReference
- cancelTimer :: forall r q. (Lifted IO q, HasCallStack, SetMember Process (Process q) r, Member Interrupts r) => TimerReference -> Eff r ()
- selectTimerElapsed :: TimerReference -> MessageSelector TimerElapsed
- 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)
- 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)
Documentation
A number of micro seconds.
Since: 0.12.0
Instances
Enum Timeout Source # | |
Eq Timeout Source # | |
Integral Timeout Source # | |
Defined in Control.Eff.Concurrent.Process.Timer | |
Num Timeout Source # | |
Ord Timeout Source # | |
Defined in Control.Eff.Concurrent.Process.Timer | |
Real Timeout Source # | |
Defined in Control.Eff.Concurrent.Process.Timer toRational :: Timeout -> Rational # | |
Show Timeout Source # | |
NFData Timeout Source # | |
Defined in Control.Eff.Concurrent.Process.Timer |
data TimerReference Source #
The reference to a timer started by startTimer
, required to stop
a timer via cancelTimer
.
Since: 0.12.0
Instances
data TimerElapsed Source #
A value to be sent when timer started with startTimer
has elapsed.
Since: 0.12.0
Instances
Eq TimerElapsed Source # | |
Defined in Control.Eff.Concurrent.Process.Timer (==) :: TimerElapsed -> TimerElapsed -> Bool # (/=) :: TimerElapsed -> TimerElapsed -> Bool # | |
Ord TimerElapsed Source # | |
Defined in Control.Eff.Concurrent.Process.Timer compare :: TimerElapsed -> TimerElapsed -> Ordering # (<) :: TimerElapsed -> TimerElapsed -> Bool # (<=) :: TimerElapsed -> TimerElapsed -> Bool # (>) :: TimerElapsed -> TimerElapsed -> Bool # (>=) :: TimerElapsed -> TimerElapsed -> Bool # max :: TimerElapsed -> TimerElapsed -> TimerElapsed # min :: TimerElapsed -> TimerElapsed -> TimerElapsed # | |
Show TimerElapsed Source # | |
Defined in Control.Eff.Concurrent.Process.Timer showsPrec :: Int -> TimerElapsed -> ShowS # show :: TimerElapsed -> String # showList :: [TimerElapsed] -> ShowS # | |
NFData TimerElapsed Source # | |
Defined in Control.Eff.Concurrent.Process.Timer rnf :: TimerElapsed -> () # |
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
selectTimerElapsed :: TimerReference -> MessageSelector TimerElapsed Source #
A MessageSelector
matching TimerElapsed
messages created by
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