2 * Unix SMB/CIFS implementation.
3 * sync dummy implementation of the pthreadpool API
4 * Copyright (C) Volker Lendecke 2009
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #include "pthreadpool.h"
26 * Indicate job completion
28 int (*signal_fn)(int jobid,
29 void (*job_fn)(void *private_data),
30 void *job_fn_private_data,
32 void *signal_fn_private_data;
35 int pthreadpool_init(unsigned max_threads, struct pthreadpool **presult,
36 int (*signal_fn)(int jobid,
37 void (*job_fn)(void *private_data),
38 void *job_fn_private_data,
40 void *signal_fn_private_data)
42 struct pthreadpool *pool;
44 pool = (struct pthreadpool *)calloc(1, sizeof(struct pthreadpool));
48 pool->signal_fn = signal_fn;
49 pool->signal_fn_private_data = signal_fn_private_data;
55 size_t pthreadpool_max_threads(struct pthreadpool *pool)
60 size_t pthreadpool_queued_jobs(struct pthreadpool *pool)
65 int pthreadpool_add_job(struct pthreadpool *pool, int job_id,
66 void (*fn)(void *private_data), void *private_data)
70 return pool->signal_fn(job_id, fn, private_data,
71 pool->signal_fn_private_data);
74 int pthreadpool_destroy(struct pthreadpool *pool)