summaryrefslogtreecommitdiff
path: root/source3/lib/pthreadpool/pthreadpool.h
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2011-04-22 11:47:11 +0200
committerVolker Lendecke <vl@samba.org>2011-04-25 09:50:32 +0200
commit62689d8166b8e070f855e6910470796dd7e1b2c8 (patch)
tree3ff4c20867ed0401753fa880b949fa98dc795012 /source3/lib/pthreadpool/pthreadpool.h
parent23a6af46c84cd9b738af403d80c5187d858eac03 (diff)
downloadsamba-62689d8166b8e070f855e6910470796dd7e1b2c8.tar.gz
samba-62689d8166b8e070f855e6910470796dd7e1b2c8.tar.bz2
samba-62689d8166b8e070f855e6910470796dd7e1b2c8.zip
s3: Many pthreadpool fixes
In particular, this makes it fork-safe
Diffstat (limited to 'source3/lib/pthreadpool/pthreadpool.h')
-rw-r--r--source3/lib/pthreadpool/pthreadpool.h42
1 files changed, 42 insertions, 0 deletions
diff --git a/source3/lib/pthreadpool/pthreadpool.h b/source3/lib/pthreadpool/pthreadpool.h
new file mode 100644
index 0000000000..7ef7ddf419
--- /dev/null
+++ b/source3/lib/pthreadpool/pthreadpool.h
@@ -0,0 +1,42 @@
+/*
+ * Unix SMB/CIFS implementation.
+ * threadpool implementation based on pthreads
+ * Copyright (C) Volker Lendecke 2009
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __PTHREADPOOL_H__
+#define __PTHREADPOOL_H__
+
+struct pthreadpool;
+
+int pthreadpool_init(unsigned max_threads, struct pthreadpool **presult);
+int pthreadpool_destroy(struct pthreadpool *pool);
+
+/*
+ * Add a job to a pthreadpool.
+ */
+int pthreadpool_add_job(struct pthreadpool *pool, int job_id,
+ void (*fn)(void *private_data), void *private_data);
+
+/*
+ * Get the signalling fd out of a thread pool. This fd will become readable
+ * when a job is finished. The job that finished can be retrieved via
+ * pthreadpool_finished_job().
+ */
+int pthreadpool_sig_fd(struct pthreadpool *pool);
+int pthreadpool_finished_job(struct pthreadpool *pool);
+
+#endif