IdrisDoc: System.Concurrency.Channels

# System.Concurrency.Channels

unsafeSend : Channel -> (val : a) -> IO Bool

  Send a message on a channel. Returns whether the message was successfully
  sent to the process at the other end of the channel. This will fail if
  the process on the channel is no longer running.
  This is unsafe because there is no type checking, so there must be
  a protocol (externally checked) which ensures that the message send
  is of type expected by the receiver.

unsafeRecv : (expected : Type) -> Channel -> IO (Maybe expected)

  Receive a message on a channel, with an explicit type.
  Blocks if there is nothing to receive. Returns `Nothing` if the
  process on the channel is no longer running.
  This is unsafe because there is no type checking, so there must be
  a protocol (externally checked) which ensures that the message received
  is of the type given by the sender.

stopThread : IO a

  Exit the thread immediately

spawn : (process : IO ()) -> IO (Maybe PID)

  Spawn a process in a new thread, returning the process ID
  Returns `Nothing` if there are not enough resources to create the new thread

listen : (timeout : Int) -> IO (Maybe Channel)

  Listen for incoming connections. If another process has initiated a
  communication with this process, returns a channel

connect : (pid : PID) -> IO (Maybe Channel)

  Create a channel which connects this process to another process

data PID : Type

  A PID is a process identifier, as returned by `spawn`

  MkPID : (pid : Ptr) -> PID
data Channel : Type

  A Channel is a connection between two processes. Channels can be created
  either using 'listen' to wait for an incoming connection, or 'connect'
  which initiates a connection to another process.
  Channels cannot (yet) be passed between processes.

  MkConc : (pid : Ptr) -> (ch_id : Int) -> Channel