ldap_rq.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /* $OpenLDAP$ */
  2. /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  3. *
  4. * Copyright 1998-2022 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. #ifndef LDAP_RQ_H
  16. #define LDAP_RQ_H 1
  17. #include <ldap_cdefs.h>
  18. LDAP_BEGIN_DECL
  19. typedef struct re_s {
  20. struct timeval next_sched;
  21. struct timeval interval;
  22. LDAP_STAILQ_ENTRY(re_s) tnext; /* it includes running */
  23. LDAP_STAILQ_ENTRY(re_s) rnext;
  24. ldap_pvt_thread_start_t *routine;
  25. void *arg;
  26. char *tname;
  27. char *tspec;
  28. void *pool_cookie;
  29. } re_t;
  30. typedef struct runqueue_s {
  31. LDAP_STAILQ_HEAD(l, re_s) task_list;
  32. LDAP_STAILQ_HEAD(rl, re_s) run_list;
  33. ldap_pvt_thread_mutex_t rq_mutex;
  34. } runqueue_t;
  35. LDAP_F( struct re_s* )
  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. char *tname,
  42. char *tspec
  43. );
  44. LDAP_F( struct re_s* )
  45. ldap_pvt_runqueue_find(
  46. struct runqueue_s* rq,
  47. ldap_pvt_thread_start_t* routine,
  48. void *arg
  49. );
  50. LDAP_F( void )
  51. ldap_pvt_runqueue_remove(
  52. struct runqueue_s* rq,
  53. struct re_s* entry
  54. );
  55. LDAP_F( struct re_s* )
  56. ldap_pvt_runqueue_next_sched(
  57. struct runqueue_s* rq,
  58. struct timeval* next_run
  59. );
  60. LDAP_F( void )
  61. ldap_pvt_runqueue_runtask(
  62. struct runqueue_s* rq,
  63. struct re_s* entry
  64. );
  65. LDAP_F( void )
  66. ldap_pvt_runqueue_stoptask(
  67. struct runqueue_s* rq,
  68. struct re_s* entry
  69. );
  70. LDAP_F( int )
  71. ldap_pvt_runqueue_isrunning(
  72. struct runqueue_s* rq,
  73. struct re_s* entry
  74. );
  75. LDAP_F( void )
  76. ldap_pvt_runqueue_resched(
  77. struct runqueue_s* rq,
  78. struct re_s* entry,
  79. int defer
  80. );
  81. LDAP_F( int )
  82. ldap_pvt_runqueue_persistent_backload(
  83. struct runqueue_s* rq
  84. );
  85. LDAP_END_DECL
  86. #endif