Пример #1
0
void li_tasklet_pool_set_threads(liTaskletPool *pool, gint threads) {
	if (threads < 0) threads = -1;
	if (pool->threads == threads) return;

	if (NULL != pool->threadpool) {
		if (pool->threads > 0 && threads > 0) {
			/* pool was exclusive, stays exlusive. just change number of threads */
			g_thread_pool_set_max_threads(pool->threadpool, threads, NULL);
			pool->threads = g_thread_pool_get_num_threads(pool->threadpool);
			/* as we already had exclusive threads running, pool->threads should be > 0 */
			return;
		}

		/* stop old pool */
		g_thread_pool_free(pool->threadpool, FALSE, TRUE);
		pool->threadpool = NULL;
	}

	if (threads != 0) {
		pool->threadpool = g_thread_pool_new(run_tasklet, pool, threads, (threads > 0), NULL);
		if (threads > 0) { /* exclusive pool, see how many threads we got */
			threads = g_thread_pool_get_num_threads(pool->threadpool);
			if (threads == 0) { /* couldn't get exlusive threads, share threads instead */
				g_thread_pool_free(pool->threadpool, FALSE, TRUE);
				pool->threadpool = g_thread_pool_new(run_tasklet, pool, -1, FALSE, NULL);
				threads = -1;
			}
		}
	}

	pool->threads = threads;
}
Пример #2
0
/**
 * entangle_pixbuf_loader_set_workers:
 * @loader: the pixbuf loader
 * @count: the new limit on workers
 *
 * Set the maximum number of worker threads for the pixbuf loader
 */
void entangle_pixbuf_loader_set_workers(EntanglePixbufLoader *loader,
                                        int count)
{
    g_return_if_fail(ENTANGLE_IS_PIXBUF_LOADER(loader));

    EntanglePixbufLoaderPrivate *priv = loader->priv;

    g_thread_pool_set_max_threads(priv->workers, count, NULL);
}
/**
 * mate_vfs_async_set_job_limit:
 * @limit: maximum number of allowable threads.
 *
 * Restrict the number of worker threads used by async operations
 * to @limit.
 */
void
mate_vfs_async_set_job_limit (int limit)
{
	if (limit < MIN_THREADS) {
		g_warning ("Attempt to set the thread_count_limit below %d", 
			   MIN_THREADS);
		return;
	}

	g_thread_pool_set_max_threads (thread_pool, limit, NULL);
}
Пример #4
0
void apply_new_config(struct nuauth_params *conf)
{
	/* checking nuauth tuning parameters */
	g_thread_pool_set_max_threads(nuauthdatas->user_workers,
			conf->nbuser_check, NULL);
	g_thread_pool_set_max_threads(nuauthdatas->acl_checkers,
			conf->nbacl_check, NULL);
	if (conf->do_ip_authentication) {
		g_thread_pool_set_max_threads(nuauthdatas->
				ip_authentication_workers,
				conf->nbipauth_check,
				NULL);
	}
	if (conf->log_users_sync) {
		g_thread_pool_set_max_threads(nuauthdatas->
				decisions_workers,
				conf->nbloggers,
				NULL);
	}
	g_thread_pool_set_max_threads(nuauthdatas->user_loggers,
			conf->nbloggers, NULL);
	g_thread_pool_set_max_threads(nuauthdatas->
			user_session_loggers,
			conf->nb_session_loggers,
			NULL);
}