Back to index

openldap  2.4.31
ldap_rq.h
Go to the documentation of this file.
00001 /* $OpenLDAP$ */
00002 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
00003  *
00004  * Copyright 1998-2012 The OpenLDAP Foundation.
00005  * All rights reserved.
00006  *
00007  * Redistribution and use in source and binary forms, with or without
00008  * modification, are permitted only as authorized by the OpenLDAP
00009  * Public License.
00010  *
00011  * A copy of this license is available in file LICENSE in the
00012  * top-level directory of the distribution or, alternatively, at
00013  * <http://www.OpenLDAP.org/license.html>.
00014  */
00015 
00016 #ifndef LDAP_RQ_H
00017 #define LDAP_RQ_H 1
00018 
00019 #include <ldap_cdefs.h>
00020 
00021 LDAP_BEGIN_DECL
00022 
00023 typedef struct re_s {
00024        struct timeval next_sched;
00025        struct timeval interval;
00026        LDAP_STAILQ_ENTRY(re_s) tnext; /* it includes running */
00027        LDAP_STAILQ_ENTRY(re_s) rnext;
00028        ldap_pvt_thread_start_t *routine;
00029        void *arg;
00030        char *tname;
00031        char *tspec;
00032 } re_t;
00033 
00034 typedef struct runqueue_s {
00035        LDAP_STAILQ_HEAD(l, re_s) task_list;
00036        LDAP_STAILQ_HEAD(rl, re_s) run_list;
00037        ldap_pvt_thread_mutex_t     rq_mutex;
00038 } runqueue_t;
00039 
00040 LDAP_F( struct re_s* )
00041 ldap_pvt_runqueue_insert(
00042        struct runqueue_s* rq,
00043        time_t interval,
00044        ldap_pvt_thread_start_t* routine,
00045        void *arg,
00046        char *tname,
00047        char *tspec
00048 );
00049 
00050 LDAP_F( struct re_s* )
00051 ldap_pvt_runqueue_find(
00052        struct runqueue_s* rq,
00053        ldap_pvt_thread_start_t* routine,
00054        void *arg
00055 );
00056 
00057 LDAP_F( void )
00058 ldap_pvt_runqueue_remove(
00059        struct runqueue_s* rq,
00060        struct re_s* entry
00061 );
00062 
00063 LDAP_F( struct re_s* )
00064 ldap_pvt_runqueue_next_sched(
00065        struct runqueue_s* rq,
00066        struct timeval* next_run
00067 );
00068 
00069 LDAP_F( void )
00070 ldap_pvt_runqueue_runtask(
00071        struct runqueue_s* rq,
00072        struct re_s* entry
00073 );
00074 
00075 LDAP_F( void )
00076 ldap_pvt_runqueue_stoptask(
00077        struct runqueue_s* rq,
00078        struct re_s* entry
00079 );
00080 
00081 LDAP_F( int )
00082 ldap_pvt_runqueue_isrunning(
00083        struct runqueue_s* rq,
00084        struct re_s* entry
00085 );
00086 
00087 LDAP_F( void )
00088 ldap_pvt_runqueue_resched(
00089        struct runqueue_s* rq,
00090        struct re_s* entry,
00091        int defer
00092 );
00093 
00094 LDAP_F( int )
00095 ldap_pvt_runqueue_persistent_backload(
00096        struct runqueue_s* rq
00097 );
00098 
00099 LDAP_END_DECL
00100 
00101 #endif