Back to index

lightning-sunbird  0.9+nobinonly
prrwlock.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is the Netscape Portable Runtime (NSPR).
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998-2000
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either the GNU General Public License Version 2 or later (the "GPL"), or
00026  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 
00038 /*
00039 ** File:             prrwlock.h
00040 ** Description:      API to basic reader-writer lock functions of NSPR.
00041 **
00042 **/
00043 
00044 #ifndef prrwlock_h___
00045 #define prrwlock_h___
00046 
00047 #include "prtypes.h"
00048 
00049 PR_BEGIN_EXTERN_C
00050 
00051 /*
00052  * PRRWLock --
00053  *
00054  *     The reader writer lock, PRRWLock, is an opaque object to the clients
00055  *     of NSPR.  All routines operate on a pointer to this opaque entity.
00056  */
00057 
00058 
00059 typedef struct PRRWLock PRRWLock;
00060 
00061 #define       PR_RWLOCK_RANK_NONE  0
00062 
00063 
00064 /***********************************************************************
00065 ** FUNCTION:    PR_NewRWLock
00066 ** DESCRIPTION:
00067 **  Returns a pointer to a newly created reader-writer lock object.
00068 ** INPUTS:      Lock rank
00069 **                          Lock name
00070 ** OUTPUTS:     void
00071 ** RETURN:      PRRWLock*
00072 **   If the lock cannot be created because of resource constraints, NULL
00073 **   is returned.
00074 **  
00075 ***********************************************************************/
00076 NSPR_API(PRRWLock*) PR_NewRWLock(PRUint32 lock_rank, const char *lock_name);
00077 
00078 /***********************************************************************
00079 ** FUNCTION:    PR_DestroyRWLock
00080 ** DESCRIPTION:
00081 **  Destroys a given RW lock object.
00082 ** INPUTS:      PRRWLock *lock - Lock to be freed.
00083 ** OUTPUTS:     void
00084 ** RETURN:      None
00085 ***********************************************************************/
00086 NSPR_API(void) PR_DestroyRWLock(PRRWLock *lock);
00087 
00088 /***********************************************************************
00089 ** FUNCTION:    PR_RWLock_Rlock
00090 ** DESCRIPTION:
00091 **  Apply a read lock (non-exclusive) on a RWLock
00092 ** INPUTS:      PRRWLock *lock - Lock to be read-locked.
00093 ** OUTPUTS:     void
00094 ** RETURN:      None
00095 ***********************************************************************/
00096 NSPR_API(void) PR_RWLock_Rlock(PRRWLock *lock);
00097 
00098 /***********************************************************************
00099 ** FUNCTION:    PR_RWLock_Wlock
00100 ** DESCRIPTION:
00101 **  Apply a write lock (exclusive) on a RWLock
00102 ** INPUTS:      PRRWLock *lock - Lock to write-locked.
00103 ** OUTPUTS:     void
00104 ** RETURN:      None
00105 ***********************************************************************/
00106 NSPR_API(void) PR_RWLock_Wlock(PRRWLock *lock);
00107 
00108 /***********************************************************************
00109 ** FUNCTION:    PR_RWLock_Unlock
00110 ** DESCRIPTION:
00111 **  Release a RW lock. Unlocking an unlocked lock has undefined results.
00112 ** INPUTS:      PRRWLock *lock - Lock to unlocked.
00113 ** OUTPUTS:     void
00114 ** RETURN:      void
00115 ***********************************************************************/
00116 NSPR_API(void) PR_RWLock_Unlock(PRRWLock *lock);
00117 
00118 PR_END_EXTERN_C
00119 
00120 #endif /* prrwlock_h___ */