ThreadPool.this

This function creates a new thread pool.

Whenever you call Thread.poolPush, either a new thread is created or an unused one is reused. At most max_threads threads are running concurrently for this thread pool. max_threads = -1 allows unlimited threads to be created for this thread pool. The newly created or reused thread now executes the function func with the two arguments. The first one is the parameter to Thread.poolPush and the second one is user_data.

The parameter exclusive determines whether the thread pool owns all threads exclusive or shares them with other thread pools. If exclusive is TRUE, max_threads threads are started immediately and they will run exclusively for this thread pool until it is destroyed by Thread.poolFree. If exclusive is FALSE, threads are created when needed and shared between all non-exclusive thread pools. This implies that max_threads may not be -1 for exclusive thread pools. Besides, exclusive thread pools are not affected by Thread.poolSetMaxIdleTime since their threads are never considered idle and returned to the global pool.

error can be NULL to ignore errors, or non-NULL to report errors. An error can only occur when exclusive is set to TRUE and not all max_threads threads could be created. See GThreadError for possible errors that may occur. Note, even in case of error a valid glib.ThreadPool is returned.

  1. this(GThreadPool* gThreadPool, bool ownedRef)
  2. this(GFunc func, void* userData, int maxThreads, bool exclusive)
    class ThreadPool
    this

Parameters

func GFunc

a function to execute in the threads of the new thread pool

userData void*

user data that is handed over to func every time it is called

maxThreads int

the maximal number of threads to execute concurrently in the new thread pool, -1 means no limit

exclusive bool

should this thread pool be exclusive?

Return Value

Throws

GException on failure. ConstructionException GTK+ fails to create the object.