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/. */
5
6/*
7** File: prrwlock.h
8** Description: API to basic reader-writer lock functions of NSPR.
9**
10**/
11
12#ifndef prrwlock_h___
13#define prrwlock_h___
14
15#include "prtypes.h"
16
17PR_BEGIN_EXTERN_C
18
19/*
20 * PRRWLock --
21 *
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.
24 */
25
26
27typedef struct PRRWLock PRRWLock;
28
29#define PR_RWLOCK_RANK_NONE 0
30
31
32/***********************************************************************
33** FUNCTION: PR_NewRWLock
34** DESCRIPTION:
35** Returns a pointer to a newly created reader-writer lock object.
36** INPUTS: Lock rank
37** Lock name
38** OUTPUTS: void
39** RETURN: PRRWLock*
40** If the lock cannot be created because of resource constraints, NULL
41** is returned.
42**
43***********************************************************************/
44NSPR_API(PRRWLock*) PR_NewRWLock(PRUint32 lock_rank, const char *lock_name);
45
46/***********************************************************************
47** FUNCTION: PR_DestroyRWLock
48** DESCRIPTION:
49** Destroys a given RW lock object.
50** INPUTS: PRRWLock *lock - Lock to be freed.
51** OUTPUTS: void
52** RETURN: None
53***********************************************************************/
54NSPR_API(void) PR_DestroyRWLock(PRRWLock *lock);
55
56/***********************************************************************
57** FUNCTION: PR_RWLock_Rlock
58** DESCRIPTION:
59** Apply a read lock (non-exclusive) on a RWLock
60** INPUTS: PRRWLock *lock - Lock to be read-locked.
61** OUTPUTS: void
62** RETURN: None
63***********************************************************************/
64NSPR_API(void) PR_RWLock_Rlock(PRRWLock *lock);
65
66/***********************************************************************
67** FUNCTION: PR_RWLock_Wlock
68** DESCRIPTION:
69** Apply a write lock (exclusive) on a RWLock
70** INPUTS: PRRWLock *lock - Lock to write-locked.
71** OUTPUTS: void
72** RETURN: None
73***********************************************************************/
74NSPR_API(void) PR_RWLock_Wlock(PRRWLock *lock);
75
76/***********************************************************************
77** FUNCTION: PR_RWLock_Unlock
78** DESCRIPTION:
79** Release a RW lock. Unlocking an unlocked lock has undefined results.
80** INPUTS: PRRWLock *lock - Lock to unlocked.
81** OUTPUTS: void
82** RETURN: void
83***********************************************************************/
84NSPR_API(void) PR_RWLock_Unlock(PRRWLock *lock);
85
86PR_END_EXTERN_C
87
88#endif /* prrwlock_h___ */
89

source code of include/nspr/prrwlock.h