prpdce.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. /*
  6. * File: prpdce.h
  7. * Description: This file is the API defined to allow for DCE (aka POSIX)
  8. * thread emulation in an NSPR environment. It is not the
  9. * intent that this be a fully supported API.
  10. */
  11. #if !defined(PRPDCE_H)
  12. #define PRPDCE_H
  13. #include "prlock.h"
  14. #include "prcvar.h"
  15. #include "prtypes.h"
  16. #include "prinrval.h"
  17. PR_BEGIN_EXTERN_C
  18. #define _PR_NAKED_CV_LOCK (PRLock*)0xdce1dce1
  19. /*
  20. ** Test and acquire a lock.
  21. **
  22. ** If the lock is acquired by the calling thread, the
  23. ** return value will be PR_SUCCESS. If the lock is
  24. ** already held, by another thread or this thread, the
  25. ** result will be PR_FAILURE.
  26. */
  27. NSPR_API(PRStatus) PRP_TryLock(PRLock *lock);
  28. /*
  29. ** Create a naked condition variable
  30. **
  31. ** A "naked" condition variable is one that is not created bound
  32. ** to a lock. The CV created with this function is the only type
  33. ** that may be used in the subsequent "naked" condition variable
  34. ** operations (see PRP_NakedWait, PRP_NakedNotify, PRP_NakedBroadcast);
  35. */
  36. NSPR_API(PRCondVar*) PRP_NewNakedCondVar(void);
  37. /*
  38. ** Destroy a naked condition variable
  39. **
  40. ** Destroy the condition variable created by PR_NewNakedCondVar.
  41. */
  42. NSPR_API(void) PRP_DestroyNakedCondVar(PRCondVar *cvar);
  43. /*
  44. ** Wait on a condition
  45. **
  46. ** Wait on the condition variable 'cvar'. It is asserted that
  47. ** the lock protecting the condition 'lock' is held by the
  48. ** calling thread. If more time expires than that declared in
  49. ** 'timeout' the condition will be notified. Waits can be
  50. ** interrupted by another thread.
  51. **
  52. ** NB: The CV ('cvar') must be one created using PR_NewNakedCondVar.
  53. */
  54. NSPR_API(PRStatus) PRP_NakedWait(
  55. PRCondVar *cvar, PRLock *lock, PRIntervalTime timeout);
  56. /*
  57. ** Notify a thread waiting on a condition
  58. **
  59. ** Notify the condition specified 'cvar'.
  60. **
  61. ** NB: The CV ('cvar') must be one created using PR_NewNakedCondVar.
  62. */
  63. NSPR_API(PRStatus) PRP_NakedNotify(PRCondVar *cvar);
  64. /*
  65. ** Notify all threads waiting on a condition
  66. **
  67. ** Notify the condition specified 'cvar'.
  68. **
  69. ** NB: The CV ('cvar') must be one created using PR_NewNakedCondVar.
  70. */
  71. NSPR_API(PRStatus) PRP_NakedBroadcast(PRCondVar *cvar);
  72. PR_END_EXTERN_C
  73. #endif /* PRPDCE_H */