No matching definitions.

tur/chan

stdlib/chan.tur

synchronous and async buffered channels for inter-fiber communication.

Since: Phase T19-C

defn

chan-new

(chan-new [cap :int] :ptr<void>)

allocate a new synchronous blocking channel with the given capacity.

capring-buffer capacity (number of int64_t slots)

An opaque ptr<void> handle to the ChanBlock.

(let [ch (chan-new 8)] ...)  ; => ptr<void>

Since: Phase T19-C

defn

chan-send

(chan-send [ch :ptr<void> val :int] :nil)

send a value into a synchronous channel, blocking when full.

chchannel handle returned by chan-new
valint64_t value to enqueue
(chan-send ch 42)

Since: Phase T19-C

defn

chan-recv

(chan-recv [ch :ptr<void>] :int)

receive a value from a synchronous channel, blocking when empty.

chchannel handle returned by chan-new

The next int64_t value dequeued from the channel.

(let [v (chan-recv ch)] ...)  ; => int

Since: Phase T19-C

defn

chan-free

(chan-free [ch :ptr<void>] :nil)

destroy a synchronous channel and release all associated memory.

chchannel handle returned by chan-new
(chan-free ch)

Since: Phase T19-C

defn

async-chan-new

(async-chan-new [cap :int] :ptr<void>)

allocate a new async buffered channel with the given capacity.

capring-buffer capacity (number of int64_t slots)

An opaque ptr<void> handle to the ChanBlock.

(let [ch (async-chan-new 16)] ...)  ; => ptr<void>

Since: Phase T19-D

defn

async-chan-send

(async-chan-send [ch :ptr<void> val :int] :nil)

send a value into an async channel, blocking when full.

chchannel handle returned by async-chan-new
valint64_t value to enqueue
(async-chan-send ch 99)

Since: Phase T19-D

defn

async-chan-recv

(async-chan-recv [ch :ptr<void>] :int)

receive a value from an async channel, blocking when empty.

chchannel handle returned by async-chan-new

The next int64_t value dequeued from the channel.

(let [v (async-chan-recv ch)] ...)  ; => int

Since: Phase T19-D

defn

async-chan-try-send

(async-chan-try-send [ch :ptr<void> val :int] :bool)

attempt to send a value without blocking.

chchannel handle returned by async-chan-new
valint64_t value to enqueue

true if the value was enqueued; false if the channel was full.

(if (async-chan-try-send ch 7) ...)  ; => bool

Since: Phase T19-D

defn

async-chan-try-recv

(async-chan-try-recv [ch :ptr<void>] :int)

attempt to receive a value without blocking.

chchannel handle returned by async-chan-new

The dequeued int64_t value, or INT64_MIN if the channel was empty.

(let [v (async-chan-try-recv ch)] ...)  ; => int (INT64_MIN = empty)

Since: Phase T19-D

defn

async-chan-count

(async-chan-count [ch :ptr<void>] :int)

return the number of items currently in an async channel.

chchannel handle returned by async-chan-new

The current item count as an int.

(async-chan-count ch)  ; => int

Since: Phase T19-D

defn

async-chan-free

(async-chan-free [ch :ptr<void>] :nil)

destroy an async channel and release all associated memory.

chchannel handle returned by async-chan-new
(async-chan-free ch)

Since: Phase T19-D