# System.Concurrency.Raw

stopThread : IO a
sendToThread : (thread_id : Ptr) -> (channel : Int) -> a -> IO Int

  Send a message of any type to the thread with the given thread id
  Returns channel ID if the message was sent successfully, 0 otherwise

  channel

    an ID of a specific channel to send the message on. If 0,
    the receiver will create a new channel ID

listenMsgs : IO (Maybe (Ptr, Int))

  Check for messages initiating a conversation in the process inbox.
  Returns either 'Nothing', if none, or 'Just (pid, channel)' as pid
  of sender and new channel id.

getMsgWithSender : IO (Ptr, Int, a)

  Check inbox for messages. If there are none, blocks until a message
  arrives. Return triple of sender's ID, channel ID, and the message.
  Note that this is not at all type safe! It is intended to be used in
  a type safe wrapper.

getMsgFrom : Ptr -> (channel : Int) -> IO (Maybe a)

  Check inbox for messages on a particular channel. If there are none,
  blocks until a message arrives. Returns `Nothing` if the sender isn't
  alive

getMsg : IO a

  Check inbox for messages. If there are none, blocks until a message
  arrives.
  Note that this is not at all type safe! It is intended to be used in
  a type safe wrapper.

checkMsgsTimeout : Int -> IO Bool

  Check for messages in the process inbox
  If no messages, waits for the given number of seconds

checkMsgsFrom : Ptr -> (channel : Int) -> IO Bool

  Check for messages from a specific sender/channel in the process inbox
  If channel is '0', accept on any channel.

checkMsgs : IO Bool

  Check for messages in the process inbox