home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / nspr30-e.zip / nspr30-e / include / prlock.h < prev    next >
C/C++ Source or Header  |  1998-07-21  |  4KB  |  103 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:        prlock.h
  21. ** Description:    API to basic locking functions of NSPR.
  22. **
  23. **
  24. ** NSPR provides basic locking mechanisms for thread synchronization.  Locks 
  25. ** are lightweight resource contention controls that prevent multiple threads 
  26. ** from accessing something (code/data) simultaneously.
  27. **/
  28.  
  29. #ifndef prlock_h___
  30. #define prlock_h___
  31.  
  32. #include "prtypes.h"
  33.  
  34. PR_BEGIN_EXTERN_C
  35.  
  36. /**********************************************************************/
  37. /************************* TYPES AND CONSTANTS ************************/
  38. /**********************************************************************/
  39.  
  40. /*
  41.  * PRLock --
  42.  *
  43.  *     NSPR represents the lock as an opaque entity to the client of the
  44.  *       API.  All routines operate on a pointer to this opaque entity.
  45.  */
  46.  
  47. typedef struct PRLock PRLock;
  48.  
  49. /**********************************************************************/
  50. /****************************** FUNCTIONS *****************************/
  51. /**********************************************************************/
  52.  
  53. /***********************************************************************
  54. ** FUNCTION:    PR_NewLock
  55. ** DESCRIPTION:
  56. **  Returns a pointer to a newly created opaque lock object.
  57. ** INPUTS:      void
  58. ** OUTPUTS:     void
  59. ** RETURN:      PRLock*
  60. **   If the lock can not be created because of resource constraints, NULL
  61. **   is returned.
  62. **  
  63. ***********************************************************************/
  64. PR_EXTERN(PRLock*) PR_NewLock(void);
  65.  
  66. /***********************************************************************
  67. ** FUNCTION:    PR_DestroyLock
  68. ** DESCRIPTION:
  69. **  Destroys a given opaque lock object.
  70. ** INPUTS:      PRLock *lock
  71. **              Lock to be freed.
  72. ** OUTPUTS:     void
  73. ** RETURN:      None
  74. ***********************************************************************/
  75. PR_EXTERN(void) PR_DestroyLock(PRLock *lock);
  76.  
  77. /***********************************************************************
  78. ** FUNCTION:    PR_Lock
  79. ** DESCRIPTION:
  80. **  Lock a lock.
  81. ** INPUTS:      PRLock *lock
  82. **              Lock to locked.
  83. ** OUTPUTS:     void
  84. ** RETURN:      None
  85. ***********************************************************************/
  86. PR_EXTERN(void) PR_Lock(PRLock *lock);
  87.  
  88. /***********************************************************************
  89. ** FUNCTION:    PR_Unlock
  90. ** DESCRIPTION:
  91. **  Unlock a lock.  Unlocking an unlocked lock has undefined results.
  92. ** INPUTS:      PRLock *lock
  93. **              Lock to unlocked.
  94. ** OUTPUTS:     void
  95. ** RETURN:      PR_STATUS
  96. **              Returns PR_FAILURE if the caller does not own the lock.
  97. ***********************************************************************/
  98. PR_EXTERN(PRStatus) PR_Unlock(PRLock *lock);
  99.  
  100. PR_END_EXTERN_C
  101.  
  102. #endif /* prlock_h___ */
  103.