Channel<T> Class
Namespace: Stride.Core.MicroThreadingAssembly: Stride.Core.MicroThreading.dll
Provides a communication mechanism between MicroThread.
public class Channel<T>
Type Parameters
Name | Description |
---|---|
T | The type of element handled by this channel. |
Remarks
MicroThread can send and receive to a
Name | Description | |
---|---|---|
Constructors | ||
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). |
|
Preference | Gets or sets the preference, allowing you to customize how Send(T) and Receive() behave regarding scheduling. |
|
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. |
|
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. |
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
Type | Description |
---|---|
System.Int32 | 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
Type | Description |
---|---|
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
Type | Description |
---|---|
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
Type | Name | Description |
---|---|---|
T | data | The data. |
Returns
Type | Description |
---|---|
ChannelMicroThreadAwaiter<T> | Awaitable data. |