1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/nsprpub/pr/include/prpdce.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,86 @@ 1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +/* 1.10 + * File: prpdce.h 1.11 + * Description: This file is the API defined to allow for DCE (aka POSIX) 1.12 + * thread emulation in an NSPR environment. It is not the 1.13 + * intent that this be a fully supported API. 1.14 + */ 1.15 + 1.16 +#if !defined(PRPDCE_H) 1.17 +#define PRPDCE_H 1.18 + 1.19 +#include "prlock.h" 1.20 +#include "prcvar.h" 1.21 +#include "prtypes.h" 1.22 +#include "prinrval.h" 1.23 + 1.24 +PR_BEGIN_EXTERN_C 1.25 + 1.26 +#define _PR_NAKED_CV_LOCK (PRLock*)0xdce1dce1 1.27 + 1.28 +/* 1.29 +** Test and acquire a lock. 1.30 +** 1.31 +** If the lock is acquired by the calling thread, the 1.32 +** return value will be PR_SUCCESS. If the lock is 1.33 +** already held, by another thread or this thread, the 1.34 +** result will be PR_FAILURE. 1.35 +*/ 1.36 +NSPR_API(PRStatus) PRP_TryLock(PRLock *lock); 1.37 + 1.38 +/* 1.39 +** Create a naked condition variable 1.40 +** 1.41 +** A "naked" condition variable is one that is not created bound 1.42 +** to a lock. The CV created with this function is the only type 1.43 +** that may be used in the subsequent "naked" condition variable 1.44 +** operations (see PRP_NakedWait, PRP_NakedNotify, PRP_NakedBroadcast); 1.45 +*/ 1.46 +NSPR_API(PRCondVar*) PRP_NewNakedCondVar(void); 1.47 + 1.48 +/* 1.49 +** Destroy a naked condition variable 1.50 +** 1.51 +** Destroy the condition variable created by PR_NewNakedCondVar. 1.52 +*/ 1.53 +NSPR_API(void) PRP_DestroyNakedCondVar(PRCondVar *cvar); 1.54 + 1.55 +/* 1.56 +** Wait on a condition 1.57 +** 1.58 +** Wait on the condition variable 'cvar'. It is asserted that 1.59 +** the lock protecting the condition 'lock' is held by the 1.60 +** calling thread. If more time expires than that declared in 1.61 +** 'timeout' the condition will be notified. Waits can be 1.62 +** interrupted by another thread. 1.63 +** 1.64 +** NB: The CV ('cvar') must be one created using PR_NewNakedCondVar. 1.65 +*/ 1.66 +NSPR_API(PRStatus) PRP_NakedWait( 1.67 + PRCondVar *cvar, PRLock *lock, PRIntervalTime timeout); 1.68 + 1.69 +/* 1.70 +** Notify a thread waiting on a condition 1.71 +** 1.72 +** Notify the condition specified 'cvar'. 1.73 +** 1.74 +** NB: The CV ('cvar') must be one created using PR_NewNakedCondVar. 1.75 +*/ 1.76 +NSPR_API(PRStatus) PRP_NakedNotify(PRCondVar *cvar); 1.77 + 1.78 +/* 1.79 +** Notify all threads waiting on a condition 1.80 +** 1.81 +** Notify the condition specified 'cvar'. 1.82 +** 1.83 +** NB: The CV ('cvar') must be one created using PR_NewNakedCondVar. 1.84 +*/ 1.85 +NSPR_API(PRStatus) PRP_NakedBroadcast(PRCondVar *cvar); 1.86 + 1.87 +PR_END_EXTERN_C 1.88 + 1.89 +#endif /* PRPDCE_H */