flint_request_threads, flint_give_back_threads
#include <flint/thread_support.h>slong flint_request_threads(thread_pool_handle ** handles, slong thread_limit)sourcevoid flint_give_back_threads(thread_pool_handle * handles, slong num_handles)sourceflint_request_threads obtains workers from the global pool for a computation that may use thread_limit threads in total, counting the caller. It stores an array of handles in *handles and returns the number w of workers obtained: 0 if \mathit{thread\_limit} \le 1, and otherwise at most \min(\mathit{thread\_limit}, \texttt{flint\_get\_num\_threads()}) - 1. flint_give_back_threads returns the workers and frees the array.
These are wrappers of thread_pool_request and thread_pool_give_back for global_thread_pool. flint_request_threads may obtain fewer workers than allowed, or none, when other threads hold part of the pool. It may allocate the array even when it returns w = 0, so always call flint_give_back_threads(handles, w); it accepts a NULL array. The guide Using the thread pool directly shows how to wake, wait for and give back the workers.
Guides#
- Using the thread pool directly (
thread_pool)
The FLINT team, “flint_request_threads, flint_give_back_threads (thread_support.h),” FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev, 2026. https://flintlib.org/doc/thread_support/flint_request_threads.html (generated 2026-10-20).
@misc{flint-doc-thread-support-flint-request-threads,
author = {{The FLINT team}},
title = {{flint\_request\_threads, flint\_give\_back\_threads (thread\_support.h)}},
howpublished = {FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev},
year = {2026},
url = {https://flintlib.org/doc/thread_support/flint_request_threads.html},
note = {Generated 2026-10-20}
}