Struct
GLibThreadPool
Description
struct GThreadPool {
GFunc func;
gpointer user_data;
gboolean exclusive;
}
The GThreadPool
struct represents a thread pool. It has three
public read-only members, but the underlying struct is bigger,
so you must not copy this struct.
Structure members
func
The function to execute in the threads of this pool.
user_data
The user data for the threads of this pool.
exclusive
Are all threads exclusive to this pool.
Functions
g_thread_pool_get_max_idle_time
This function will return the maximum interval
that a
thread will wait in the thread pool for new tasks before
being stopped.
since: 2.10
g_thread_pool_new_full
This function creates a new thread pool similar to g_thread_pool_new()
but allowing item_free_func
to be specified to free the data passed
to g_thread_pool_push()
in the case that the GThreadPool
is stopped
and freed before all tasks have been executed.
since: 2.70
g_thread_pool_set_max_idle_time
This function will set the maximum interval
that a thread
waiting in the pool for new tasks can be idle for before
being stopped. This function is similar to calling
g_thread_pool_stop_unused_threads()
on a regular timeout,
except this is done on a per thread basis.
since: 2.10
g_thread_pool_set_max_unused_threads
Sets the maximal number of unused threads to max_threads
.
If max_threads
is -1, no limit is imposed on the number
of unused threads.
g_thread_pool_stop_unused_threads
Stops all currently unused threads. This does not change the maximal number of unused threads. This function can be used to regularly stop all unused threads e.g. from g_timeout_add().
Instance methods
g_thread_pool_move_to_front
Moves the item to the front of the queue of unprocessed items, so that it will be processed next.
since: 2.46
g_thread_pool_set_max_threads
Sets the maximal allowed number of threads for pool
.
A value of -1 means that the maximal number of threads
is unlimited. If pool
is an exclusive thread pool, setting
the maximal number of threads to -1 is not allowed.
g_thread_pool_set_sort_function
Sets the function used to sort the list of tasks. This allows the
tasks to be processed by a priority determined by func
, and not
just in the order in which they were added to the pool.
since: 2.10