]> git.sur5r.net Git - openldap/blob - include/ldap_rq.h
Added ldap_pvt_runqueue_find()
[openldap] / include / ldap_rq.h
1 /* $OpenLDAP$ */
2 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
3  *
4  * Copyright 1998-2005 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 } re_t;
31
32 typedef struct runqueue_s {
33         LDAP_STAILQ_HEAD(l, re_s) task_list;
34         LDAP_STAILQ_HEAD(rl, re_s) run_list;
35         ldap_pvt_thread_mutex_t rq_mutex;
36 } runqueue_t;
37
38 LDAP_F( void )
39 ldap_pvt_runqueue_insert(
40         struct runqueue_s* rq,
41         time_t interval,
42         ldap_pvt_thread_start_t* routine,
43         void *arg
44 );
45
46 LDAP_F( struct re_s* )
47 ldap_pvt_runqueue_find(
48         struct runqueue_s* rq,
49         ldap_pvt_thread_start_t* routine,
50         void *arg
51 );
52
53 LDAP_F( void )
54 ldap_pvt_runqueue_remove(
55         struct runqueue_s* rq,
56         struct re_s* entry
57 );
58
59 LDAP_F( struct re_s* )
60 ldap_pvt_runqueue_next_sched(
61         struct runqueue_s* rq,
62         struct timeval** next_run
63 );
64
65 LDAP_F( void )
66 ldap_pvt_runqueue_runtask(
67         struct runqueue_s* rq,
68         struct re_s* entry
69 );
70
71 LDAP_F( void )
72 ldap_pvt_runqueue_stoptask(
73         struct runqueue_s* rq,
74         struct re_s* entry
75 );
76
77 LDAP_F( int )
78 ldap_pvt_runqueue_isrunning(
79         struct runqueue_s* rq,
80         struct re_s* entry
81 );
82
83 LDAP_F( void )
84 ldap_pvt_runqueue_resched(
85         struct runqueue_s* rq,
86         struct re_s* entry,
87         int defer
88 );
89
90 LDAP_F( int )
91 ldap_pvt_runqueue_persistent_backload(
92         struct runqueue_s* rq
93 );
94
95 LDAP_END_DECL
96
97 #endif