Exemple #1
0
//*****************************************************************************************
//销毁thiz 所指向的线程池对象;
//成功返回0, 失败返回 -1;
//*****************************************************************************************
int threadpool_destroy(ThreadPool *thiz) {
    return_val_if_fail(thiz, -1);
    free(thiz->task_queue_);
    free(thiz->task_fun_);
    threadpool_stop_all_task(thiz);
    pthread_mutex_destroy(&thiz->mutex_);
    pthread_cond_destroy(&thiz->cond_);
    free(thiz);
    thiz = NULL;
 
    return 0;
}
int	threadpool_destroy(threadpool_t *thiz)
{
	return_val_if_fail(thiz, -1);
	threadpool_stop_all_task(thiz);
	free(thiz->task_queue->arg);
	free(thiz->task_queue->task_func);
	free(thiz->task_queue);
	free(thiz->thread_id);
	pthread_mutex_destroy(&thiz->mutex_queue);
	pthread_mutex_destroy(&thiz->mutex_cond);
	pthread_cond_destroy(&thiz->cond);
	thiz = NULL;
	return 0;
}