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/. */
8 ** Description: API to basic reader-writer lock functions of NSPR.
22 * The reader writer lock, PRRWLock, is an opaque object to the clients
23 * of NSPR. All routines operate on a pointer to this opaque entity.
27 typedef struct PRRWLock PRRWLock
;
29 #define PR_RWLOCK_RANK_NONE 0
32 /***********************************************************************
33 ** FUNCTION: PR_NewRWLock
35 ** Returns a pointer to a newly created reader-writer lock object.
40 ** If the lock cannot be created because of resource constraints, NULL
43 ***********************************************************************/
44 NSPR_API(PRRWLock
*) PR_NewRWLock(PRUint32 lock_rank
, const char *lock_name
);
46 /***********************************************************************
47 ** FUNCTION: PR_DestroyRWLock
49 ** Destroys a given RW lock object.
50 ** INPUTS: PRRWLock *lock - Lock to be freed.
53 ***********************************************************************/
54 NSPR_API(void) PR_DestroyRWLock(PRRWLock
*lock
);
56 /***********************************************************************
57 ** FUNCTION: PR_RWLock_Rlock
59 ** Apply a read lock (non-exclusive) on a RWLock
60 ** INPUTS: PRRWLock *lock - Lock to be read-locked.
63 ***********************************************************************/
64 NSPR_API(void) PR_RWLock_Rlock(PRRWLock
*lock
);
66 /***********************************************************************
67 ** FUNCTION: PR_RWLock_Wlock
69 ** Apply a write lock (exclusive) on a RWLock
70 ** INPUTS: PRRWLock *lock - Lock to write-locked.
73 ***********************************************************************/
74 NSPR_API(void) PR_RWLock_Wlock(PRRWLock
*lock
);
76 /***********************************************************************
77 ** FUNCTION: PR_RWLock_Unlock
79 ** Release a RW lock. Unlocking an unlocked lock has undefined results.
80 ** INPUTS: PRRWLock *lock - Lock to unlocked.
83 ***********************************************************************/
84 NSPR_API(void) PR_RWLock_Unlock(PRRWLock
*lock
);
88 #endif /* prrwlock_h___ */