]> git.sur5r.net Git - openldap/blob - include/ldap_rq.h
Add ldap_pvt_thread_pool_queues decl
[openldap] / include / ldap_rq.h
1 /* $OpenLDAP$ */
2 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
3  *
4  * Copyright 1998-2017 The OpenLDAP Foundation.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted only as authorized by the OpenLDAP
9  * Public License.
10  *
11  * A copy of this license is available in file LICENSE in the
12  * top-level directory of the distribution or, alternatively, at
13  * <http://www.OpenLDAP.org/license.html>.
14  */
15
16 #ifndef LDAP_RQ_H
17 #define LDAP_RQ_H 1
18
19 #include <ldap_cdefs.h>
20
21 LDAP_BEGIN_DECL
22
23 typedef struct re_s {
24         struct timeval next_sched;
25         struct timeval interval;
26         LDAP_STAILQ_ENTRY(re_s) tnext; /* it includes running */
27         LDAP_STAILQ_ENTRY(re_s) rnext;
28         ldap_pvt_thread_start_t *routine;
29         void *arg;
30         char *tname;
31         char *tspec;
32         void *pool_cookie;
33 } re_t;
34
35 typedef struct runqueue_s {
36         LDAP_STAILQ_HEAD(l, re_s) task_list;
37         LDAP_STAILQ_HEAD(rl, re_s) run_list;
38         ldap_pvt_thread_mutex_t rq_mutex;
39 } runqueue_t;
40
41 LDAP_F( struct re_s* )
42 ldap_pvt_runqueue_insert(
43         struct runqueue_s* rq,
44         time_t interval,
45         ldap_pvt_thread_start_t* routine,
46         void *arg,
47         char *tname,
48         char *tspec
49 );
50
51 LDAP_F( struct re_s* )
52 ldap_pvt_runqueue_find(
53         struct runqueue_s* rq,
54         ldap_pvt_thread_start_t* routine,
55         void *arg
56 );
57
58 LDAP_F( void )
59 ldap_pvt_runqueue_remove(
60         struct runqueue_s* rq,
61         struct re_s* entry
62 );
63
64 LDAP_F( struct re_s* )
65 ldap_pvt_runqueue_next_sched(
66         struct runqueue_s* rq,
67         struct timeval* next_run
68 );
69
70 LDAP_F( void )
71 ldap_pvt_runqueue_runtask(
72         struct runqueue_s* rq,
73         struct re_s* entry
74 );
75
76 LDAP_F( void )
77 ldap_pvt_runqueue_stoptask(
78         struct runqueue_s* rq,
79         struct re_s* entry
80 );
81
82 LDAP_F( int )
83 ldap_pvt_runqueue_isrunning(
84         struct runqueue_s* rq,
85         struct re_s* entry
86 );
87
88 LDAP_F( void )
89 ldap_pvt_runqueue_resched(
90         struct runqueue_s* rq,
91         struct re_s* entry,
92         int defer
93 );
94
95 LDAP_F( int )
96 ldap_pvt_runqueue_persistent_backload(
97         struct runqueue_s* rq
98 );
99
100 LDAP_END_DECL
101
102 #endif