selftest: Prepare to allow override of lockout duration in password_lockout tests
[Samba.git] / lib / pthreadpool / pthreadpool_tevent.h
blob6c939fc1d2d8761b476d9a8c08ec23f5ae7e75ec
1 /*
2 * Unix SMB/CIFS implementation.
3 * threadpool implementation based on pthreads
4 * Copyright (C) Volker Lendecke 2016
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/>.
20 #ifndef __PTHREADPOOL_TEVENT_H__
21 #define __PTHREADPOOL_TEVENT_H__
23 #include <tevent.h>
25 void pthreadpool_tevent_cleanup_orphaned_jobs(void);
27 struct pthreadpool_tevent;
29 int pthreadpool_tevent_init(TALLOC_CTX *mem_ctx, unsigned max_threads,
30 struct pthreadpool_tevent **presult);
32 struct pthreadpool_tevent_wrapper_ops {
33 const char *name;
35 bool (*before_job)(struct pthreadpool_tevent *wrap_tp,
36 void *private_state,
37 struct pthreadpool_tevent *main_tp,
38 const char *location);
39 bool (*after_job)(struct pthreadpool_tevent *wrap_tp,
40 void *private_state,
41 struct pthreadpool_tevent *main_tp,
42 const char *location);
45 struct pthreadpool_tevent *_pthreadpool_tevent_wrapper_create(
46 struct pthreadpool_tevent *main_tp,
47 TALLOC_CTX *mem_ctx,
48 const struct pthreadpool_tevent_wrapper_ops *ops,
49 void *pstate,
50 size_t psize,
51 const char *type,
52 const char *location);
53 #define pthreadpool_tevent_wrapper_create(main_tp, mem_ctx, ops, state, type) \
54 _pthreadpool_tevent_wrapper_create(main_tp, mem_ctx, ops, \
55 state, sizeof(type), #type, __location__)
58 * this can only be called directly after
59 * pthreadpool_tevent_wrapper_create()
61 void pthreadpool_tevent_force_per_thread_cwd(struct pthreadpool_tevent *pool,
62 const void *private_state);
64 size_t pthreadpool_tevent_max_threads(struct pthreadpool_tevent *pool);
65 size_t pthreadpool_tevent_queued_jobs(struct pthreadpool_tevent *pool);
66 bool pthreadpool_tevent_per_thread_cwd(struct pthreadpool_tevent *pool);
69 * return true - if tevent_req_cancel() was called.
71 bool pthreadpool_tevent_current_job_canceled(void);
73 * return true - if talloc_free() was called on the job request,
74 * tevent_context or pthreadpool_tevent.
76 bool pthreadpool_tevent_current_job_orphaned(void);
78 * return true if canceled and orphaned are both false.
80 bool pthreadpool_tevent_current_job_continue(void);
83 * return true if the current job can rely on a per thread
84 * current working directory.
86 bool pthreadpool_tevent_current_job_per_thread_cwd(void);
88 struct tevent_req *pthreadpool_tevent_job_send(
89 TALLOC_CTX *mem_ctx, struct tevent_context *ev,
90 struct pthreadpool_tevent *pool,
91 void (*fn)(void *private_data), void *private_data);
93 int pthreadpool_tevent_job_recv(struct tevent_req *req);
95 #endif