Exemple #1
0
/* Initialize queue */
static int jobqueue_init(thpool_* thpool_p){
	thpool_p->jobqueue_p = (struct jobqueue*)malloc(sizeof(struct jobqueue));
	if (thpool_p->jobqueue_p == NULL){
		return -1;
	}
    memset(thpool_p->jobqueue_p, 0, sizeof(struct jobqueue));
	thpool_p->jobqueue_p->has_jobs = (struct bsem*)malloc(sizeof(struct bsem));
	if (thpool_p->jobqueue_p->has_jobs == NULL){
		return -1;
	}
    memset(thpool_p->jobqueue_p->has_jobs, 0, sizeof(struct bsem));
	bsem_init(thpool_p->jobqueue_p->has_jobs, 0);
	jobqueue_clear(thpool_p);
	return 0;
}
Exemple #2
0
/* Initialize queue */
static int jobqueue_init(thpool_* thpool_p){
	thpool_p->jobqueue_p = (struct jobqueue*)malloc(sizeof(struct jobqueue));
	thpool_p->jobqueue_p->len = 0;
	pthread_mutex_init(&(thpool_p->jobqueue_p->rwmutex), NULL);
	if (thpool_p->jobqueue_p == NULL){
		return -1;
	}
	thpool_p->jobqueue_p->has_jobs = (struct bsem*)malloc(sizeof(struct bsem));
	if (thpool_p->jobqueue_p->has_jobs == NULL){
		return -1;
	}
	bsem_init(thpool_p->jobqueue_p->has_jobs, 0);
	jobqueue_clear(thpool_p);
	return 0;
}
Exemple #3
0
/* Free all queue resources back to the system */
static void jobqueue_destroy(thpool_* thpool_p){
	jobqueue_clear(thpool_p);
	free(thpool_p->jobqueue_p->has_jobs);
}
Exemple #4
0
/* Free all queue resources back to the system */
static void jobqueue_destroy(jobqueue* jobqueue_p)
{
    jobqueue_clear(jobqueue_p);
    free(jobqueue_p->has_jobs);
}
Exemple #5
0
/* Free all queue resources back to the system */
static void jobqueue_destroy(ThPool* thpool) {
    jobqueue_clear(thpool);
    free(thpool->jobqueue->has_jobs);
}