ThreadPool

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.

Constructors

this
this(GThreadPool* gThreadPool, bool ownedRef)

Sets our main struct and passes it to the parent class.

this
this(GFunc func, void* userData, int maxThreads, bool exclusive)

This function creates a new thread pool.

Members

Functions

free
void free(bool immediate, bool wait)

Frees all resources allocated for @pool.

getMaxThreads
int getMaxThreads()

Returns the maximal number of threads for @pool.

getNumThreads
uint getNumThreads()

Returns the number of threads currently running in @pool.

getStruct
void* getStruct()

the main Gtk struct as a void*

getThreadPoolStruct
GThreadPool* getThreadPoolStruct()

Get the main Gtk struct

moveToFront
bool moveToFront(void* data)

Moves the item to the front of the queue of unprocessed items, so that it will be processed next.

push
bool push(void* data)

Inserts @data into the list of tasks to be executed by @pool.

setMaxThreads
bool setMaxThreads(int maxThreads)

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.

setSortFunction
void setSortFunction(GCompareDataFunc func, void* userData)

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.

unprocessed
uint unprocessed()

Returns the number of tasks still unprocessed in @pool.

Static functions

getMaxIdleTime
uint getMaxIdleTime()

This function will return the maximum @interval that a thread will wait in the thread pool for new tasks before being stopped.

getMaxUnusedThreads
int getMaxUnusedThreads()

Returns the maximal allowed number of unused threads.

getNumUnusedThreads
uint getNumUnusedThreads()

Returns the number of currently unused threads.

setMaxIdleTime
void setMaxIdleTime(uint interval)

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.

setMaxUnusedThreads
void setMaxUnusedThreads(int maxThreads)

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.

stopUnusedThreads
void stopUnusedThreads()

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().

Variables

gThreadPool
GThreadPool* gThreadPool;

the main Gtk struct

ownedRef
bool ownedRef;
Undocumented in source.

Meta