Table of Contents

Class Channel<T>

Namespace
Stride.Core.MicroThreading
Assembly
Stride.Core.MicroThreading.dll

Provides a communication mechanism between MicroThread.

public class Channel<T>

Type Parameters

T

The type of element handled by this channel.

Inheritance
Channel<T>

Remarks

MicroThread can send and receive to a Channel. Depending on the Channel.Preference, sending or receiving MicroThread might be suspended and yield execution to another MicroThread.

Constructors

Channel()

public Channel()

Properties

Balance

Gets the balance, which is the number of MicroThread waiting to send (if greater than 0) or receive (if smaller than 0).

public int Balance { get; }

Property Value

int

The balance.

Preference

Gets or sets the preference, allowing you to customize how Send(T) and Receive() behave regarding scheduling.

public ChannelPreference Preference { get; set; }

Property Value

ChannelPreference

The preference.

Methods

Receive()

Receives a value over the channel. If no other MicroThread is sending data, the receiver will be blocked. If someone was sending data, which of the sender or receiver continues next depends on Preference.

public ChannelMicroThreadAwaiter<T> Receive()

Returns

ChannelMicroThreadAwaiter<T>

Awaitable data.

Reset()

public void Reset()

Send(T)

Sends a value over the channel. If no other MicroThread is waiting for data, the sender will be blocked. If someone was waiting for data, which of the sender or receiver continues next depends on Preference.

public ChannelMicroThreadAwaiter<T> Send(T data)

Parameters

data T

The data.

Returns

ChannelMicroThreadAwaiter<T>

Awaitable data.