No matching definitions.

schan

stdlib/schan.tur

session-typed channel wrappers over a linear opaque handle.

Since: S1

defopaque

SSend

(SSend [T R] :int))

protocol step: send a value of type T, then continue as R.

defopaque

SRecv

(SRecv [T R] :int))

protocol step: receive a value of type T, then continue as R.

defopaque

SClose

(SClose)

protocol terminus: the channel is closed.

defopaque linear

SChan

(SChan [P] :ptr<void>)

a linear channel handle carrying a protocol phantom P.

Since: S1

defn

schan-new

(schan-new [P])

open a session-typed channel running protocol P.

capring-buffer capacity (>= 1)

A fresh SChan<P>. The protocol P is fixed by the call site's expected type (or an ascription).

(:: (schan-new 4) (SChan (SSend int SClose)))  ; => SChan<SSend int SClose>

Since: S1

defn

schan-send

(schan-send [T R])

send a T over a channel whose protocol begins with SSend T R.

cchannel at protocol SSend<T R> (consumed)
vthe value to send

The same channel, advanced to protocol R.

(let [c2 (schan-send c 42)] ...)  ; c : SChan<SSend int R> => c2 : SChan<R>

Since: S1

defn

schan-recv

(schan-recv [T R])
defn

schan-close

(schan-close [c : (SChan SClose)] :)

close a channel whose protocol has reached SClose.

cchannel at protocol SClose (consumed)

nil. The underlying channel is freed.

(schan-close c)   ; c : SChan<SClose>

Since: S1

Internal definitions
schan-recv-value-- receive a T from a channel whose protocol begins with SRecv T R.
schan-advance-recv-- internal: retag the channel from SRecv T R to R.