PageRenderTime 33ms CodeModel.GetById 27ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/gecko_api/include/prrwlock.h

http://firefox-mac-pdf.googlecode.com/
C++ Header | 120 lines | 13 code | 16 blank | 91 comment | 0 complexity | 2387a7d1ca3f44bd1ec7e5c0b09f957d MD5 | raw file
  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
  4 *
  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/
  9 *
 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
 13 * License.
 14 *
 15 * The Original Code is the Netscape Portable Runtime (NSPR).
 16 *
 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.
 21 *
 22 * Contributor(s):
 23 *
 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.
 35 *
 36 * ***** END LICENSE BLOCK ***** */
 37
 38/*
 39** File:		prrwlock.h
 40** Description:	API to basic reader-writer lock functions of NSPR.
 41**
 42**/
 43
 44#ifndef prrwlock_h___
 45#define prrwlock_h___
 46
 47#include "prtypes.h"
 48
 49PR_BEGIN_EXTERN_C
 50
 51/*
 52 * PRRWLock --
 53 *
 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.
 56 */
 57
 58
 59typedef struct PRRWLock PRRWLock;
 60
 61#define	PR_RWLOCK_RANK_NONE	0
 62
 63
 64/***********************************************************************
 65** FUNCTION:    PR_NewRWLock
 66** DESCRIPTION:
 67**  Returns a pointer to a newly created reader-writer lock object.
 68** INPUTS:      Lock rank
 69**				Lock name
 70** OUTPUTS:     void
 71** RETURN:      PRRWLock*
 72**   If the lock cannot be created because of resource constraints, NULL
 73**   is returned.
 74**  
 75***********************************************************************/
 76NSPR_API(PRRWLock*) PR_NewRWLock(PRUint32 lock_rank, const char *lock_name);
 77
 78/***********************************************************************
 79** FUNCTION:    PR_DestroyRWLock
 80** DESCRIPTION:
 81**  Destroys a given RW lock object.
 82** INPUTS:      PRRWLock *lock - Lock to be freed.
 83** OUTPUTS:     void
 84** RETURN:      None
 85***********************************************************************/
 86NSPR_API(void) PR_DestroyRWLock(PRRWLock *lock);
 87
 88/***********************************************************************
 89** FUNCTION:    PR_RWLock_Rlock
 90** DESCRIPTION:
 91**  Apply a read lock (non-exclusive) on a RWLock
 92** INPUTS:      PRRWLock *lock - Lock to be read-locked.
 93** OUTPUTS:     void
 94** RETURN:      None
 95***********************************************************************/
 96NSPR_API(void) PR_RWLock_Rlock(PRRWLock *lock);
 97
 98/***********************************************************************
 99** FUNCTION:    PR_RWLock_Wlock
100** DESCRIPTION:
101**  Apply a write lock (exclusive) on a RWLock
102** INPUTS:      PRRWLock *lock - Lock to write-locked.
103** OUTPUTS:     void
104** RETURN:      None
105***********************************************************************/
106NSPR_API(void) PR_RWLock_Wlock(PRRWLock *lock);
107
108/***********************************************************************
109** FUNCTION:    PR_RWLock_Unlock
110** DESCRIPTION:
111**  Release a RW lock. Unlocking an unlocked lock has undefined results.
112** INPUTS:      PRRWLock *lock - Lock to unlocked.
113** OUTPUTS:     void
114** RETURN:      void
115***********************************************************************/
116NSPR_API(void) PR_RWLock_Unlock(PRRWLock *lock);
117
118PR_END_EXTERN_C
119
120#endif /* prrwlock_h___ */