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