Safe Haskell | None |
---|---|
Language | Haskell2010 |
This module provides bounded channels similar to those seen in the Go programming language.
Types
The core data type. A
provides a conduit through which messages
of type Chan
αα
can be sent and received.
The Result
record represents the result of waiting to recieve a message
on a given channel.
When used with chanSelect
, a
provides a means of waiting for a
Case
αSend
or Recv
to complete on a given channel, subsequently invoking the
given callback.
Functions
chanTryRecv :: Chan a -> IO (Maybe (Result a)) Source #
Attempt to receive a message on a channel. A message will be recieved iff the channel has a message in its buffer or another thread is waiting to send a message on this channel.
chanSend :: Chan a -> a -> IO () Source #
Wait to successfully send a message on a channel.
Throws an exception when sending on a closed channel.
chanTrySend :: Chan a -> a -> IO Bool Source #
Attempt to send a message on a channel. The message will be sent iff the channel has spare space in its buffer or another thread is waiting to recieve a message on this channel.
Returns True
iff the message was sent.
Throws an exception when sending on a closed channel.
:: [Case a] | The list of cases. |
-> Maybe (IO a) | When |
-> IO a | The value resulting from the selected |
When no default action is given, blocks until one of the cases can run, then it executes that case. It chooses one at random if multiple are ready.
If given a default action, and no cases can run, immediately executes the default action.