Skip to content
FutureBlitz

    Install

    Import std.concurrent.concurrent_queue

    std.concurrent.concurrent_queue

    ConcurrentQueue<T>: first in, first out, for any number of threads at once, with no limit but memory and what an Int counts. The values are in a Channel, which is a ring, behind a Mutex, and a Channel twice the size takes its place once it's full, so Enqueue never waits for room, and TryDequeue never waits for a value: a Channel is what waits.

    std/concurrent/concurrent_queue.fb

    Types

    ConcurrentQueue class

    Public Shared Class ConcurrentQueue<T: Sendable> Implements Defaultable

    A first in, first out queue that threads share, which any of them adds to and takes from.

    std/concurrent/concurrent_queue.fb, line 24

    • Public New() constructor #

      A new, empty ConcurrentQueue.

    • Public Property Count: Int property #

      How many values there are, which other threads may change at any time.

    • @PanicsAtCaller Public Method Enqueue(value: T) method #

      Puts value at the back. Panics when the ConcurrentQueue has as many values as an Int counts.

    • @PanicsAtCaller Public Method Add(value: T) method #

      The same as Enqueue.

    • @PanicsAtCaller Public Method AddAll(values: Iterable<T>) method #

      Enqueues each of the values, in order, all read first. Other threads' may come between them.

    • Public Method TryDequeue(): T? method #

      Takes the front value off and gives it, or Null when the ConcurrentQueue is empty.

    • Public Method TryPeek(): T? method #

      The front value, which stays, or Null when the ConcurrentQueue is empty.

    • Public Method ToArray(): T[] method #

      The values from the front, the order TryDequeue gives them, in a new array.

    • Public Method Clear() method #

      Removes every value. They go once it holds no lock, so a Destroy that their going runs can use the ConcurrentQueue.

    • Public Static Method DefaultValue(): ConcurrentQueue<T> static method #

      A new, empty ConcurrentQueue.

    Report an issue with this page or with FutureBlitz on GitHub.