1/* $NetBSD: ldap_rq.h,v 1.1.1.3 2010/12/12 15:21:24 adam Exp $ */ 2 3/* OpenLDAP: pkg/ldap/include/ldap_rq.h,v 1.14.2.6 2010/04/13 20:22:49 kurt Exp */ 4/* This work is part of OpenLDAP Software <http://www.openldap.org/>. 5 * 6 * Copyright 1998-2010 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 23LDAP_BEGIN_DECL 24 25typedef 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 36typedef 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 42LDAP_F( struct re_s* ) 43ldap_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 52LDAP_F( struct re_s* ) 53ldap_pvt_runqueue_find( 54 struct runqueue_s* rq, 55 ldap_pvt_thread_start_t* routine, 56 void *arg 57); 58 59LDAP_F( void ) 60ldap_pvt_runqueue_remove( 61 struct runqueue_s* rq, 62 struct re_s* entry 63); 64 65LDAP_F( struct re_s* ) 66ldap_pvt_runqueue_next_sched( 67 struct runqueue_s* rq, 68 struct timeval* next_run 69); 70 71LDAP_F( void ) 72ldap_pvt_runqueue_runtask( 73 struct runqueue_s* rq, 74 struct re_s* entry 75); 76 77LDAP_F( void ) 78ldap_pvt_runqueue_stoptask( 79 struct runqueue_s* rq, 80 struct re_s* entry 81); 82 83LDAP_F( int ) 84ldap_pvt_runqueue_isrunning( 85 struct runqueue_s* rq, 86 struct re_s* entry 87); 88 89LDAP_F( void ) 90ldap_pvt_runqueue_resched( 91 struct runqueue_s* rq, 92 struct re_s* entry, 93 int defer 94); 95 96LDAP_F( int ) 97ldap_pvt_runqueue_persistent_backload( 98 struct runqueue_s* rq 99); 100 101LDAP_END_DECL 102 103#endif 104