+
+/**
+ * g_thread_pool_set_sort_function:
+ * @pool: a #GThreadPool
+ * @func: the #GCompareDataFunc used to sort the list of tasks.
+ * This function is passed two tasks. It should return
+ * 0 if the order in which they are handled does not matter,
+ * a negative value if the first task should be processed before
+ * the second or a positive value if the second task should be
+ * processed first.
+ * @user_data: user data passed to @func
+ *
+ * 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.
+ *
+ * Note, if the maximum number of threads is more than 1, the order
+ * that threads are executed cannot be guaranteed 100%. Threads are
+ * scheduled by the operating system and are executed at random. It
+ * cannot be assumed that threads are executed in the order they are
+ * created.
+ *
+ * Since: 2.10
+ */
+void
+g_thread_pool_set_sort_function (GThreadPool *pool,
+ GCompareDataFunc func,
+ gpointer user_data)
+{
+ GRealThreadPool *real;
+
+ real = (GRealThreadPool*) pool;
+
+ g_return_if_fail (real);
+ g_return_if_fail (real->running);
+
+ g_async_queue_lock (real->queue);
+
+ real->sort_func = func;
+ real->sort_user_data = user_data;
+
+ if (func)
+ g_async_queue_sort_unlocked (real->queue,
+ real->sort_func,
+ real->sort_user_data);
+
+ g_async_queue_unlock (real->queue);
+}
+
+/**
+ * g_thread_pool_set_max_idle_time:
+ * @interval: the maximum @interval (in milliseconds)
+ * a thread can be idle
+ *
+ * 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.
+ *
+ * By setting @interval to 0, idle threads will not be stopped.
+ *
+ * The default value is 15000 (15 seconds).
+ *
+ * Since: 2.10
+ */
+void
+g_thread_pool_set_max_idle_time (guint interval)
+{
+ guint i;
+
+ g_atomic_int_set (&max_idle_time, interval);
+
+ i = g_atomic_int_get (&unused_threads);
+ if (i > 0)
+ {
+ g_atomic_int_inc (&wakeup_thread_serial);
+ g_async_queue_lock (unused_thread_queue);
+
+ do
+ {
+ g_async_queue_push_unlocked (unused_thread_queue,
+ wakeup_thread_marker);
+ }
+ while (--i);
+
+ g_async_queue_unlock (unused_thread_queue);
+ }
+}
+
+/**
+ * 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.
+ *
+ * If this function returns 0, threads waiting in the thread
+ * pool for new work are not stopped.
+ *
+ * Returns: the maximum @interval (milliseconds) to wait
+ * for new tasks in the thread pool before stopping the
+ * thread
+ *
+ * Since: 2.10
+ */
+guint
+g_thread_pool_get_max_idle_time (void)
+{
+ return g_atomic_int_get (&max_idle_time);
+}