Basics
Guides
API Reference
Basics
Guides
API Reference
[34:7] extends: object
The GThreadPool struct represents a thread pool. A thread pool is useful
when you wish to asynchronously fork out the execution of work and continue
working in your own thread. If that will happen often, the overhead of
starting and destroying a thread each time might be too high. In such cases
reusing already started threads seems like a good idea. And it indeed is, but
implementing this can be tedious and error-prone. Therefore GLib provides
thread pools for your convenience. An added advantage is, that the threads
can be shared between the different subsystems of your program, when they are
using GLib. To create a new thread pool, you use [func@GLib.ThreadPool.new].
It is destroyed by [method@GLib.ThreadPool.free]. If you want to execute a
certain task within a thread pool, use [method@GLib.ThreadPool.push]. To get
the current number of running threads you call
[method@GLib.ThreadPool.get_num_threads]. To get the number of still
unprocessed tasks you call [method@GLib.ThreadPool.unprocessed]. To control
the maximum number of threads for a thread pool, you use
[method@GLib.ThreadPool.get_max_threads]. and
[method@GLib.ThreadPool.set_max_threads]. Finally you can control the number
of unused threads, that are kept alive by GLib for future use. The current
number can be fetched with [func@GLib.ThreadPool.get_num_unused_threads]. The
maximum number can be controlled by
[func@GLib.ThreadPool.get_max_unused_threads] and
[func@GLib.ThreadPool.set_max_unused_threads]. All currently unused threads
can be stopped by calling [func@GLib.ThreadPool.stop_unused_threads].
ThreadPool (Handle = null)
Creates a new
ThreadPoolby wrapping a native handle or another wrapper.
Handle is the native handle or another wrapper whose handle to adopt.toNativeHandle (Source)
Normalizes a constructor argument into a raw pointer carrier. Accepts a raw NativeHandle, a raw NativeBuffer returned from
fn.call(...), another generated wrapper exposinghandle(), or null. Returns null when the argument carries no pointer.
Source is the raw handle, raw buffer, wrapper, or null.A raw pointer carrier or null when no pointer is present.getLib ()
Returns the opened native library for this generated wrapper.
The opened native library.handle ()
Returns the wrapped NativeHandle.
The wrapped NativeHandle.isNull ()
Returns true when the wrapped handle is null.
A bool.describe ()
Returns a small string for debugging generated wrappers.
A string.
Aussom
Write once. Embed everywhere.
Copyright 2026 Austin Lehman. All rights reserved.