futures.Channel
Object → futures.Channel
A channel is a queue-type object that can be used by multiple coroutines.
Constructor
Channel(maxsize: number?): futures.ChannelFields
| Name | Type | Description |
|---|---|---|
max_size | integer | Maximum size of the channel. |
Methods
close | Closes the channel. |
isClosed | Returns true if the channel is closed, false otherwise. |
isEmpty | Returns true if the channel is empty, false otherwise. |
isFull | Returns true if the channel is full, false otherwise. |
pop | Gets a value from the channel. |
push | Puts a value into the channel. |
#Channel:close
function futures.Channel:close()
Closes the channel.
#Channel:isClosed
function futures.Channel:isClosed(): boolean
Returns true if the channel is closed, false otherwise.
Returns
| Type | Name | Description |
|---|---|---|
boolean | isClosed |
#Channel:isEmpty
function futures.Channel:isEmpty(): boolean
Returns true if the channel is empty, false otherwise.
Returns
| Type | Name | Description |
|---|---|---|
boolean | isEmpty |
#Channel:isFull
function futures.Channel:isFull(): boolean
Returns true if the channel is full, false otherwise.
Returns
| Type | Name | Description |
|---|---|---|
boolean | isFull |
#Channel:pop
function futures.Channel:pop(force?: boolean): T | nil
Gets a value from the channel.
Parameters
| Name | Type | Description |
|---|---|---|
forceoptional | boolean | If true, pop without waiting for a value even if the channel is empty. |
Returns
| Type | Name | Description |
|---|---|---|
T | nil | value |
#Channel:push
function futures.Channel:push(value: T, force?: boolean): boolean
Puts a value into the channel.
Parameters
| Name | Type | Description |
|---|---|---|
value | T | The value to push. Must not be nil. |
forceoptional | boolean | If true, push without waiting for space, bypassing the max-size check. |
Returns
| Type | Name | Description |
|---|---|---|
boolean | success |