osip_condv.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*
  2. The oSIP library implements the Session Initiation Protocol (SIP -rfc3261-)
  3. Copyright (C) 2001-2020 Aymeric MOIZARD amoizard@antisip.com
  4. This library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. This library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with this library; if not, write to the Free Software
  14. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  15. */
  16. #ifndef __OSIP_CONDV_H__
  17. #define __OSIP_CONDV_H__
  18. #include <stdio.h>
  19. #ifndef OSIP_MONOTHREAD
  20. /**
  21. * @file osip_condv.h
  22. * @brief oSIP condition variables definitions
  23. *
  24. * Those methods are only available if the library is compile
  25. * in multi threaded mode. This is the default for oSIP.
  26. */
  27. /**
  28. * @defgroup oSIP_COND oSIP condition variables definitions
  29. * @ingroup osip2_port
  30. * @{
  31. */
  32. #ifdef __cplusplus
  33. extern "C" {
  34. #endif
  35. #if defined(__PSOS__)
  36. /* TODO */
  37. #else
  38. /* condv implementation */
  39. #if defined(WIN32) || defined(_WIN32_WCE)
  40. /* Prevent struct redefinition if Pthreads for Win32 is used */
  41. #if (_MSC_VER < 1900)
  42. #ifndef HAVE_STRUCT_TIMESPEC
  43. #define HAVE_STRUCT_TIMESPEC 1
  44. /**
  45. * timespec structure
  46. * @struct timespec
  47. */
  48. struct timespec {
  49. long tv_sec;
  50. long tv_nsec;
  51. };
  52. #endif
  53. #endif
  54. #endif
  55. struct osip_cond;
  56. /**
  57. * Allocate and Initialise a condition variable
  58. */
  59. struct osip_cond *osip_cond_init(void);
  60. /**
  61. * Destroy a condition variable
  62. * @param cond The condition variable to destroy.
  63. */
  64. int osip_cond_destroy(struct osip_cond *cond);
  65. /**
  66. * Signal the condition variable.
  67. * @param cond The condition variable to signal.
  68. */
  69. int osip_cond_signal(struct osip_cond *cond);
  70. /**
  71. * Wait on the condition variable.
  72. * @param cond The condition variable to wait on.
  73. * @param mut The external mutex
  74. */
  75. int osip_cond_wait(struct osip_cond *cond, struct osip_mutex *mut);
  76. /**
  77. * Timed wait on the condition variable.
  78. * @param cond The condition variable to wait on.
  79. * @param mut The external mutex
  80. * @param abstime time to wait until
  81. */
  82. int osip_cond_timedwait(struct osip_cond *cond, struct osip_mutex *mut, const struct timespec *abstime);
  83. #ifdef __cplusplus
  84. }
  85. #endif
  86. #endif
  87. /** @} */
  88. #endif
  89. #endif