xref: /netbsd-src/external/bsd/openldap/dist/include/ldap_rq.h (revision 466a16a118933bd295a8a104f095714fadf9cf68)
1 /* $OpenLDAP: pkg/ldap/include/ldap_rq.h,v 1.14.2.4 2008/02/11 23:26:40 kurt Exp $ */
2 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
3  *
4  * Copyright 1998-2008 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 } re_t;
33 
34 typedef struct runqueue_s {
35 	LDAP_STAILQ_HEAD(l, re_s) task_list;
36 	LDAP_STAILQ_HEAD(rl, re_s) run_list;
37 	ldap_pvt_thread_mutex_t	rq_mutex;
38 } runqueue_t;
39 
40 LDAP_F( struct re_s* )
41 ldap_pvt_runqueue_insert(
42 	struct runqueue_s* rq,
43 	time_t interval,
44 	ldap_pvt_thread_start_t* routine,
45 	void *arg,
46 	char *tname,
47 	char *tspec
48 );
49 
50 LDAP_F( struct re_s* )
51 ldap_pvt_runqueue_find(
52 	struct runqueue_s* rq,
53 	ldap_pvt_thread_start_t* routine,
54 	void *arg
55 );
56 
57 LDAP_F( void )
58 ldap_pvt_runqueue_remove(
59 	struct runqueue_s* rq,
60 	struct re_s* entry
61 );
62 
63 LDAP_F( struct re_s* )
64 ldap_pvt_runqueue_next_sched(
65 	struct runqueue_s* rq,
66 	struct timeval* next_run
67 );
68 
69 LDAP_F( void )
70 ldap_pvt_runqueue_runtask(
71 	struct runqueue_s* rq,
72 	struct re_s* entry
73 );
74 
75 LDAP_F( void )
76 ldap_pvt_runqueue_stoptask(
77 	struct runqueue_s* rq,
78 	struct re_s* entry
79 );
80 
81 LDAP_F( int )
82 ldap_pvt_runqueue_isrunning(
83 	struct runqueue_s* rq,
84 	struct re_s* entry
85 );
86 
87 LDAP_F( void )
88 ldap_pvt_runqueue_resched(
89 	struct runqueue_s* rq,
90 	struct re_s* entry,
91 	int defer
92 );
93 
94 LDAP_F( int )
95 ldap_pvt_runqueue_persistent_backload(
96 	struct runqueue_s* rq
97 );
98 
99 LDAP_END_DECL
100 
101 #endif
102