Class (GI Class)

Dex-1DexThreadPoolSince 1.2

Dex.ThreadPool is a thread pool for managing native OS threads similar to GLib.ThreadPool.

The threads managed by Dex.ThreadPool do not contain a Dex.Scheduler which means that you cannot await futures or schedule Dex.Block from a worker thread.

Threads are created up-front from Dex.ThreadPool.new.

Dex.ThreadPool primarily exists for situations where you are using blocking external libraries and want to avoid calling Dex.thread_spawn without any sort of queuing or bounding on the permitted concurrency.

1.2

Hierarchy (View Summary)

Index
  • Gets the fixed number of threads owned by the pool.

    Returns number

    the number of threads in the pool

    1.2

  • Queues blocking work to run on one of the pool's reusable threads.

    The provided thread_name is applied to the returned future using dex_future_set_static_name() so that tracing and debugging tools can identify the work item. It does not rename the underlying OS worker thread.

    Parameters

    • thread_name: string

      the name to use for debugging the returned future

    • thread_func: Dex.ThreadFunc

      the function to run on a pooled thread

    Returns Dex.Future

    a future that resolves when the work completes

    1.2

  • Releases a reference on the given object, and decreases its reference count by one.

    If it was the last reference, the resources associated to the instance are freed.

    Returns void

Interfaces

SignalSignatures