home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / nsprpub / pr / include / prpdce.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  2.9 KB  |  96 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. #define _PR_NAKED_CV_LOCK (PRLock*)0xdce1dce1
  35.  
  36. /*
  37. ** Test and acquire a lock.
  38. **
  39. ** If the lock is acquired by the calling thread, the
  40. ** return value will be PR_SUCCESS. If the lock is
  41. ** already held, by another thread or this thread, the
  42. ** result will be PR_FAILURE.
  43. */
  44. PR_EXTERN(PRStatus) PRP_TryLock(PRLock *lock);
  45.  
  46. /*
  47. ** Create a naked condition variable
  48. **
  49. ** A "naked" condition variable is one that is not created bound
  50. ** to a lock. The CV created with this function is the only type
  51. ** that may be used in the subsequent "naked" condition variable
  52. ** operations (see PRP_NakedWait, PRP_NakedNotify, PRP_NakedBroadcast);
  53. */
  54. PR_EXTERN(PRCondVar*) PRP_NewNakedCondVar(void);
  55.  
  56. /*
  57. ** Destroy a naked condition variable
  58. **
  59. ** Destroy the condition variable created by PR_NewNakedCondVar.
  60. */
  61. PR_EXTERN(void) PRP_DestroyNakedCondVar(PRCondVar *cvar);
  62.  
  63. /*
  64. ** Wait on a condition
  65. **
  66. ** Wait on the condition variable 'cvar'. It is asserted that
  67. ** the lock protecting the condition 'lock' is held by the
  68. ** calling thread. If more time expires than that declared in
  69. ** 'timeout' the condition will be notified. Waits can be
  70. ** interrupted by another thread.
  71. **
  72. ** NB: The CV ('cvar') must be one created using PR_NewNakedCondVar.
  73. */
  74. PR_EXTERN(PRStatus) PRP_NakedWait(
  75.     PRCondVar *cvar, PRLock *lock, PRIntervalTime timeout);
  76.  
  77. /*
  78. ** Notify a thread waiting on a condition
  79. **
  80. ** Notify the condition specified 'cvar'.
  81. **
  82. ** NB: The CV ('cvar') must be one created using PR_NewNakedCondVar.
  83. */
  84. PR_EXTERN(PRStatus) PRP_NakedNotify(PRCondVar *cvar);
  85.  
  86. /*
  87. ** Notify all threads waiting on a condition
  88. **
  89. ** Notify the condition specified 'cvar'.
  90. **
  91. ** NB: The CV ('cvar') must be one created using PR_NewNakedCondVar.
  92. */
  93. PR_EXTERN(PRStatus) PRP_NakedBroadcast(PRCondVar *cvar);
  94.  
  95. #endif /* PRPDCE_H */
  96.