/contrib/bind9/lib/isc/nothreads/include/isc/condition.h

https://bitbucket.org/freebsd/freebsd-head/ · C++ Header · 59 lines · 19 code · 13 blank · 27 comment · 1 complexity · cd895b337122c7bd97d54d6d81611875 MD5 · raw file

  1. /*
  2. * Copyright (C) 2004, 2007 Internet Systems Consortium, Inc. ("ISC")
  3. * Copyright (C) 2000, 2001 Internet Software Consortium.
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for any
  6. * purpose with or without fee is hereby granted, provided that the above
  7. * copyright notice and this permission notice appear in all copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
  10. * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  11. * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
  12. * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  13. * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  14. * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. * PERFORMANCE OF THIS SOFTWARE.
  16. */
  17. /* $Id: condition.h,v 1.6 2007/06/19 23:47:18 tbox Exp $ */
  18. /*
  19. * This provides a limited subset of the isc_condition_t
  20. * functionality for use by single-threaded programs that
  21. * need to block waiting for events. Only a single
  22. * call to isc_condition_wait() may be blocked at any given
  23. * time, and the _waituntil and _broadcast functions are not
  24. * supported. This is intended primarily for use by the omapi
  25. * library, and may go away once omapi goes away. Use for
  26. * other purposes is strongly discouraged.
  27. */
  28. #ifndef ISC_CONDITION_H
  29. #define ISC_CONDITION_H 1
  30. #include <isc/mutex.h>
  31. typedef int isc_condition_t;
  32. isc_result_t isc__nothread_wait_hack(isc_condition_t *cp, isc_mutex_t *mp);
  33. isc_result_t isc__nothread_signal_hack(isc_condition_t *cp);
  34. #define isc_condition_init(cp) \
  35. (*(cp) = 0, ISC_R_SUCCESS)
  36. #define isc_condition_wait(cp, mp) \
  37. isc__nothread_wait_hack(cp, mp)
  38. #define isc_condition_waituntil(cp, mp, tp) \
  39. ((void)(cp), (void)(mp), (void)(tp), ISC_R_NOTIMPLEMENTED)
  40. #define isc_condition_signal(cp) \
  41. isc__nothread_signal_hack(cp)
  42. #define isc_condition_broadcast(cp) \
  43. ((void)(cp), ISC_R_NOTIMPLEMENTED)
  44. #define isc_condition_destroy(cp) \
  45. (*(cp) == 0 ? (*(cp) = -1, ISC_R_SUCCESS) : ISC_R_UNEXPECTED)
  46. #endif /* ISC_CONDITION_H */