andre@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ andre@0: /* This Source Code Form is subject to the terms of the Mozilla Public andre@0: * License, v. 2.0. If a copy of the MPL was not distributed with this andre@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ andre@0: andre@0: /* andre@0: ** File: prrwlock.h andre@0: ** Description: API to basic reader-writer lock functions of NSPR. andre@0: ** andre@0: **/ andre@0: andre@0: #ifndef prrwlock_h___ andre@0: #define prrwlock_h___ andre@0: andre@0: #include "prtypes.h" andre@0: andre@0: PR_BEGIN_EXTERN_C andre@0: andre@0: /* andre@0: * PRRWLock -- andre@0: * andre@0: * The reader writer lock, PRRWLock, is an opaque object to the clients andre@0: * of NSPR. All routines operate on a pointer to this opaque entity. andre@0: */ andre@0: andre@0: andre@0: typedef struct PRRWLock PRRWLock; andre@0: andre@0: #define PR_RWLOCK_RANK_NONE 0 andre@0: andre@0: andre@0: /*********************************************************************** andre@0: ** FUNCTION: PR_NewRWLock andre@0: ** DESCRIPTION: andre@0: ** Returns a pointer to a newly created reader-writer lock object. andre@0: ** INPUTS: Lock rank andre@0: ** Lock name andre@0: ** OUTPUTS: void andre@0: ** RETURN: PRRWLock* andre@0: ** If the lock cannot be created because of resource constraints, NULL andre@0: ** is returned. andre@0: ** andre@0: ***********************************************************************/ andre@0: NSPR_API(PRRWLock*) PR_NewRWLock(PRUint32 lock_rank, const char *lock_name); andre@0: andre@0: /*********************************************************************** andre@0: ** FUNCTION: PR_DestroyRWLock andre@0: ** DESCRIPTION: andre@0: ** Destroys a given RW lock object. andre@0: ** INPUTS: PRRWLock *lock - Lock to be freed. andre@0: ** OUTPUTS: void andre@0: ** RETURN: None andre@0: ***********************************************************************/ andre@0: NSPR_API(void) PR_DestroyRWLock(PRRWLock *lock); andre@0: andre@0: /*********************************************************************** andre@0: ** FUNCTION: PR_RWLock_Rlock andre@0: ** DESCRIPTION: andre@0: ** Apply a read lock (non-exclusive) on a RWLock andre@0: ** INPUTS: PRRWLock *lock - Lock to be read-locked. andre@0: ** OUTPUTS: void andre@0: ** RETURN: None andre@0: ***********************************************************************/ andre@0: NSPR_API(void) PR_RWLock_Rlock(PRRWLock *lock); andre@0: andre@0: /*********************************************************************** andre@0: ** FUNCTION: PR_RWLock_Wlock andre@0: ** DESCRIPTION: andre@0: ** Apply a write lock (exclusive) on a RWLock andre@0: ** INPUTS: PRRWLock *lock - Lock to write-locked. andre@0: ** OUTPUTS: void andre@0: ** RETURN: None andre@0: ***********************************************************************/ andre@0: NSPR_API(void) PR_RWLock_Wlock(PRRWLock *lock); andre@0: andre@0: /*********************************************************************** andre@0: ** FUNCTION: PR_RWLock_Unlock andre@0: ** DESCRIPTION: andre@0: ** Release a RW lock. Unlocking an unlocked lock has undefined results. andre@0: ** INPUTS: PRRWLock *lock - Lock to unlocked. andre@0: ** OUTPUTS: void andre@0: ** RETURN: void andre@0: ***********************************************************************/ andre@0: NSPR_API(void) PR_RWLock_Unlock(PRRWLock *lock); andre@0: andre@0: PR_END_EXTERN_C andre@0: andre@0: #endif /* prrwlock_h___ */