15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/* 35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * The contents of this file are subject to the Mozilla Public 45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * License Version 1.1 (the "License"); you may not use this file 55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * except in compliance with the License. You may obtain a copy of 65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * the License at http://www.mozilla.org/MPL/ 75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * 85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Software distributed under the License is distributed on an "AS 95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or 105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * implied. See the License for the specific language governing 115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * rights and limitations under the License. 125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * 135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * The Original Code is the Netscape Portable Runtime (NSPR). 145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * 155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * The Initial Developer of the Original Code is Netscape 165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Communications Corporation. Portions created by Netscape are 175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Copyright (C) 1998-2000 Netscape Communications Corporation. All 185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Rights Reserved. 195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * 205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Contributor(s): 215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * 225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Alternatively, the contents of this file may be used under the 235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * terms of the GNU General Public License Version 2 or later (the 245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * "GPL"), in which case the provisions of the GPL are applicable 255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * instead of those above. If you wish to allow use of your 265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * version of this file only under the terms of the GPL and not to 275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * allow others to use your version of this file under the MPL, 285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * indicate your decision by deleting the provisions above and 295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * replace them with the notice and other provisions required by 305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * the GPL. If you do not delete the provisions above, a recipient 315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * may use your version of this file under either the MPL or the 325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * GPL. 335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */ 345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/* 365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** File: prlock.h 375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** Description: API to basic locking functions of NSPR. 385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** 395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** 405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** NSPR provides basic locking mechanisms for thread synchronization. Locks 415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** are lightweight resource contention controls that prevent multiple threads 425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** from accessing something (code/data) simultaneously. 435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**/ 445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef prlock_h___ 465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define prlock_h___ 475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "prtypes.h" 495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)PR_BEGIN_EXTERN_C 515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/**********************************************************************/ 535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/************************* TYPES AND CONSTANTS ************************/ 545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/**********************************************************************/ 555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/* 575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * PRLock -- 585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * 595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * NSPR represents the lock as an opaque entity to the client of the 605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * API. All routines operate on a pointer to this opaque entity. 615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */ 625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef struct PRLock PRLock; 645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/**********************************************************************/ 665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/****************************** FUNCTIONS *****************************/ 675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/**********************************************************************/ 685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/*********************************************************************** 705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** FUNCTION: PR_NewLock 715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** DESCRIPTION: 725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** Returns a pointer to a newly created opaque lock object. 735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** INPUTS: void 745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** OUTPUTS: void 755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** RETURN: PRLock* 765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** If the lock can not be created because of resource constraints, NULL 775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** is returned. 785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** 795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)***********************************************************************/ 805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSPR_API(PRLock*) PR_NewLock(void); 815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/*********************************************************************** 835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** FUNCTION: PR_DestroyLock 845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** DESCRIPTION: 855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** Destroys a given opaque lock object. 865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** INPUTS: PRLock *lock 875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** Lock to be freed. 885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** OUTPUTS: void 895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** RETURN: None 905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)***********************************************************************/ 915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSPR_API(void) PR_DestroyLock(PRLock *lock); 925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/*********************************************************************** 945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** FUNCTION: PR_Lock 955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** DESCRIPTION: 965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** Lock a lock. 975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** INPUTS: PRLock *lock 985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** Lock to locked. 995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** OUTPUTS: void 1005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** RETURN: None 1015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)***********************************************************************/ 1025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSPR_API(void) PR_Lock(PRLock *lock); 1035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/*********************************************************************** 1055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** FUNCTION: PR_Unlock 1065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** DESCRIPTION: 1075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** Unlock a lock. Unlocking an unlocked lock has undefined results. 1085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** INPUTS: PRLock *lock 1095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** Lock to unlocked. 1105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** OUTPUTS: void 1115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** RETURN: PR_STATUS 1125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** Returns PR_FAILURE if the caller does not own the lock. 1135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)***********************************************************************/ 1145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSPR_API(PRStatus) PR_Unlock(PRLock *lock); 1155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)PR_END_EXTERN_C 1175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif /* prlock_h___ */ 119