Stride

OPEN / CLOSE
  • Features
  • Blog
  • Documentation
  • Community
(icon) Download

  • Discord
  • Facebook
  • Twitter
  • YouTube

LANGUAGE

OPEN / CLOSE
  • English
  • 日本語
    Show / Hide Table of Contents

    Channel<T> Class

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

    Provides a communication mechanism between MicroThread.

    System.Object → Channel<T>
    Derived from Channel<T>:

    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 . Depending on the , sending or receiving MicroThread might be suspended and yield execution to another MicroThread.

    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.

    | Improve this Doc View Source

    Constructors


    Channel()

    public Channel()
    | Improve this Doc View Source

    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.

    | Improve this Doc View Source

    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.


    Extension Methods

    ComponentBaseExtensions.DisposeBy<T>(T, ICollectorHolder)
    ComponentBaseExtensions.RemoveDisposeBy<T>(T, ICollectorHolder)
    • Improve this Doc
    • View Source
    In This Article

    Back to top

    Copyright © 2019-2021 .NET Foundation and Contributors
    Supported by the .NET Foundation