IdrisDoc: System.Concurrency.Sessions

System.Concurrency.Sessions

unsafeSend : Session -> (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 : (a : Type) -> Session -> IO (Maybe a)

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.

spawn : IO () -> IO PID

Spawn a process in a new thread, returning the process ID

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

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

connect : (proc : PID) -> IO (Maybe Session)

Create a channel which connects this process to another process

data Session : Type

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

MkConc : (pid : Ptr) -> (ch_id : Int) -> Session
data PID : Type

A PID is a process identifier, as returned by spawn

MkPID : (pid : Ptr) -> PID