1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* ***** BEGIN LICENSE BLOCK *****
3
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
5
* The contents of this file are subject to the Mozilla Public License Version
6
* 1.1 (the "License"); you may not use this file except in compliance with
7
* the License. You may obtain a copy of the License at
8
* http://www.mozilla.org/MPL/
10
* Software distributed under the License is distributed on an "AS IS" basis,
11
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12
* for the specific language governing rights and limitations under the
15
* The Original Code is the Netscape Portable Runtime (NSPR).
17
* The Initial Developer of the Original Code is
18
* Netscape Communications Corporation.
19
* Portions created by the Initial Developer are Copyright (C) 1998-2000
20
* the Initial Developer. All Rights Reserved.
24
* Alternatively, the contents of this file may be used under the terms of
25
* either the GNU General Public License Version 2 or later (the "GPL"), or
26
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27
* in which case the provisions of the GPL or the LGPL are applicable instead
28
* of those above. If you wish to allow use of your version of this file only
29
* under the terms of either the GPL or the LGPL, and not to allow others to
30
* use your version of this file under the terms of the MPL, indicate your
31
* decision by deleting the provisions above and replace them with the notice
32
* and other provisions required by the GPL or the LGPL. If you do not delete
33
* the provisions above, a recipient may use your version of this file under
34
* the terms of any one of the MPL, the GPL or the LGPL.
36
* ***** END LICENSE BLOCK ***** */
40
** Description: API to basic reader-writer lock functions of NSPR.
54
* The reader writer lock, PRRWLock, is an opaque object to the clients
55
* of NSPR. All routines operate on a pointer to this opaque entity.
59
typedef struct PRRWLock PRRWLock;
61
#define PR_RWLOCK_RANK_NONE 0
64
/***********************************************************************
65
** FUNCTION: PR_NewRWLock
67
** Returns a pointer to a newly created reader-writer lock object.
72
** If the lock cannot be created because of resource constraints, NULL
75
***********************************************************************/
76
NSPR_API(PRRWLock*) PR_NewRWLock(PRUint32 lock_rank, const char *lock_name);
78
/***********************************************************************
79
** FUNCTION: PR_DestroyRWLock
81
** Destroys a given RW lock object.
82
** INPUTS: PRRWLock *lock - Lock to be freed.
85
***********************************************************************/
86
NSPR_API(void) PR_DestroyRWLock(PRRWLock *lock);
88
/***********************************************************************
89
** FUNCTION: PR_RWLock_Rlock
91
** Apply a read lock (non-exclusive) on a RWLock
92
** INPUTS: PRRWLock *lock - Lock to be read-locked.
95
***********************************************************************/
96
NSPR_API(void) PR_RWLock_Rlock(PRRWLock *lock);
98
/***********************************************************************
99
** FUNCTION: PR_RWLock_Wlock
101
** Apply a write lock (exclusive) on a RWLock
102
** INPUTS: PRRWLock *lock - Lock to write-locked.
105
***********************************************************************/
106
NSPR_API(void) PR_RWLock_Wlock(PRRWLock *lock);
108
/***********************************************************************
109
** FUNCTION: PR_RWLock_Unlock
111
** Release a RW lock. Unlocking an unlocked lock has undefined results.
112
** INPUTS: PRRWLock *lock - Lock to unlocked.
115
***********************************************************************/
116
NSPR_API(void) PR_RWLock_Unlock(PRRWLock *lock);
120
#endif /* prrwlock_h___ */