dreamworkAPI
Ctrl K
GitHub
classDocs / futures / Channel

futures.Channel

classsharedmenusource
Object → futures.Channel

A channel is a queue-type object that can be used by multiple coroutines.

Constructor

Channel(maxsize: number?): futures.Channel

Fields

NameTypeDescription
max_sizeintegerMaximum size of the channel.

Methods

closeCloses the channel.
isClosedReturns true if the channel is closed, false otherwise.
isEmptyReturns true if the channel is empty, false otherwise.
isFullReturns true if the channel is full, false otherwise.
popGets a value from the channel.
pushPuts a value into the channel.

#Channel:close

sharedmenusource
function futures.Channel:close()

Closes the channel.

#Channel:isClosed

sharedmenunodiscardsource
function futures.Channel:isClosed(): boolean

Returns true if the channel is closed, false otherwise.

Returns
TypeNameDescription
booleanisClosed

#Channel:isEmpty

sharedmenunodiscardsource
function futures.Channel:isEmpty(): boolean

Returns true if the channel is empty, false otherwise.

Returns
TypeNameDescription
booleanisEmpty

#Channel:isFull

sharedmenunodiscardsource
function futures.Channel:isFull(): boolean

Returns true if the channel is full, false otherwise.

Returns
TypeNameDescription
booleanisFull

#Channel:pop

sharedmenusource
function futures.Channel:pop(force?: boolean): T | nil

Gets a value from the channel.

Parameters
NameTypeDescription
forceoptionalbooleanIf true, pop without waiting for a value even if the channel is empty.
Returns
TypeNameDescription
T | nilvalue

#Channel:push

sharedmenusource
function futures.Channel:push(value: T, force?: boolean): boolean

Puts a value into the channel.

Parameters
NameTypeDescription
valueTThe value to push. Must not be nil.
forceoptionalbooleanIf true, push without waiting for space, bypassing the max-size check.
Returns
TypeNameDescription
booleansuccess
Generated from the dreamwork meta branch.