Arize Phoenix TS
    Preparing search index...

    Type Parameters

    • T
    Index

    Constructors

    • Create a new channel with the specified buffer capacity.

      Type Parameters

      • T

      Parameters

      • capacity: number = 10

        Buffer size (default: 10)

        • 0: Unbuffered/rendezvous channel - strict synchronization, higher deadlock risk. Use only when you need guaranteed happens-before ordering.
        • 1-100: Buffered channel - recommended for production use.
        • Higher values: Better throughput but more memory usage.

      Returns Channel<T>

      // Default buffered (safe for most cases)
      const ch1 = new Channel<number>();

      // Explicit buffer size (production pattern)
      const ch2 = new Channel<number>(50);

      // Unbuffered (advanced - strict synchronization)
      const ch3 = new Channel<number>(0);

    Accessors

    Methods

    • Send a value to the channel Blocks if the buffer is full until space is available

      Parameters

      • value: T

        The value to send

      Returns Promise<void>

      If channel is closed

    • Try to receive a value without blocking Returns immediately with value or undefined if channel is empty

      Returns typeof CLOSED | T | undefined

      The received value, CLOSED if channel is closed, or undefined if empty

      const ch = new Channel<number>(10);
      await ch.send(42);

      const value = ch.tryReceive();
      if (value !== undefined && value !== CLOSED) {
      console.log("Got:", value);
      }