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