home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / nspr30-e.zip / nspr30-e / include / prpdce.h < prev    next >
C/C++ Source or Header  |  1998-11-02  |  3KB  |  100 lines

  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /*
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  * 
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  * 
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19. /*
  20.  * File:        prpdce.h
  21.  * Description:    This file is the API defined to allow for DCE (aka POSIX)
  22.  *                thread emulation in an NSPR environment. It is not the
  23.  *                intent that this be a fully supported API.
  24.  */
  25.  
  26. #if !defined(PRPDCE_H)
  27. #define PRPDCE_H
  28.  
  29. #include "prlock.h"
  30. #include "prcvar.h"
  31. #include "prtypes.h"
  32. #include "prinrval.h"
  33.  
  34. PR_BEGIN_EXTERN_C
  35.  
  36. #define _PR_NAKED_CV_LOCK (PRLock*)0xdce1dce1
  37.  
  38. /*
  39. ** Test and acquire a lock.
  40. **
  41. ** If the lock is acquired by the calling thread, the
  42. ** return value will be PR_SUCCESS. If the lock is
  43. ** already held, by another thread or this thread, the
  44. ** result will be PR_FAILURE.
  45. */
  46. PR_EXTERN(PRStatus) PRP_TryLock(PRLock *lock);
  47.  
  48. /*
  49. ** Create a naked condition variable
  50. **
  51. ** A "naked" condition variable is one that is not created bound
  52. ** to a lock. The CV created with this function is the only type
  53. ** that may be used in the subsequent "naked" condition variable
  54. ** operations (see PRP_NakedWait, PRP_NakedNotify, PRP_NakedBroadcast);
  55. */
  56. PR_EXTERN(PRCondVar*) PRP_NewNakedCondVar(void);
  57.  
  58. /*
  59. ** Destroy a naked condition variable
  60. **
  61. ** Destroy the condition variable created by PR_NewNakedCondVar.
  62. */
  63. PR_EXTERN(void) PRP_DestroyNakedCondVar(PRCondVar *cvar);
  64.  
  65. /*
  66. ** Wait on a condition
  67. **
  68. ** Wait on the condition variable 'cvar'. It is asserted that
  69. ** the lock protecting the condition 'lock' is held by the
  70. ** calling thread. If more time expires than that declared in
  71. ** 'timeout' the condition will be notified. Waits can be
  72. ** interrupted by another thread.
  73. **
  74. ** NB: The CV ('cvar') must be one created using PR_NewNakedCondVar.
  75. */
  76. PR_EXTERN(PRStatus) PRP_NakedWait(
  77.     PRCondVar *cvar, PRLock *lock, PRIntervalTime timeout);
  78.  
  79. /*
  80. ** Notify a thread waiting on a condition
  81. **
  82. ** Notify the condition specified 'cvar'.
  83. **
  84. ** NB: The CV ('cvar') must be one created using PR_NewNakedCondVar.
  85. */
  86. PR_EXTERN(PRStatus) PRP_NakedNotify(PRCondVar *cvar);
  87.  
  88. /*
  89. ** Notify all threads waiting on a condition
  90. **
  91. ** Notify the condition specified 'cvar'.
  92. **
  93. ** NB: The CV ('cvar') must be one created using PR_NewNakedCondVar.
  94. */
  95. PR_EXTERN(PRStatus) PRP_NakedBroadcast(PRCondVar *cvar);
  96.  
  97. PR_END_EXTERN_C
  98.  
  99. #endif /* PRPDCE_H */
  100.