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: prpdce.h andre@0: * Description: This file is the API defined to allow for DCE (aka POSIX) andre@0: * thread emulation in an NSPR environment. It is not the andre@0: * intent that this be a fully supported API. andre@0: */ andre@0: andre@0: #if !defined(PRPDCE_H) andre@0: #define PRPDCE_H andre@0: andre@0: #include "prlock.h" andre@0: #include "prcvar.h" andre@0: #include "prtypes.h" andre@0: #include "prinrval.h" andre@0: andre@0: PR_BEGIN_EXTERN_C andre@0: andre@0: #define _PR_NAKED_CV_LOCK (PRLock*)0xdce1dce1 andre@0: andre@0: /* andre@0: ** Test and acquire a lock. andre@0: ** andre@0: ** If the lock is acquired by the calling thread, the andre@0: ** return value will be PR_SUCCESS. If the lock is andre@0: ** already held, by another thread or this thread, the andre@0: ** result will be PR_FAILURE. andre@0: */ andre@0: NSPR_API(PRStatus) PRP_TryLock(PRLock *lock); andre@0: andre@0: /* andre@0: ** Create a naked condition variable andre@0: ** andre@0: ** A "naked" condition variable is one that is not created bound andre@0: ** to a lock. The CV created with this function is the only type andre@0: ** that may be used in the subsequent "naked" condition variable andre@0: ** operations (see PRP_NakedWait, PRP_NakedNotify, PRP_NakedBroadcast); andre@0: */ andre@0: NSPR_API(PRCondVar*) PRP_NewNakedCondVar(void); andre@0: andre@0: /* andre@0: ** Destroy a naked condition variable andre@0: ** andre@0: ** Destroy the condition variable created by PR_NewNakedCondVar. andre@0: */ andre@0: NSPR_API(void) PRP_DestroyNakedCondVar(PRCondVar *cvar); andre@0: andre@0: /* andre@0: ** Wait on a condition andre@0: ** andre@0: ** Wait on the condition variable 'cvar'. It is asserted that andre@0: ** the lock protecting the condition 'lock' is held by the andre@0: ** calling thread. If more time expires than that declared in andre@0: ** 'timeout' the condition will be notified. Waits can be andre@0: ** interrupted by another thread. andre@0: ** andre@0: ** NB: The CV ('cvar') must be one created using PR_NewNakedCondVar. andre@0: */ andre@0: NSPR_API(PRStatus) PRP_NakedWait( andre@0: PRCondVar *cvar, PRLock *lock, PRIntervalTime timeout); andre@0: andre@0: /* andre@0: ** Notify a thread waiting on a condition andre@0: ** andre@0: ** Notify the condition specified 'cvar'. andre@0: ** andre@0: ** NB: The CV ('cvar') must be one created using PR_NewNakedCondVar. andre@0: */ andre@0: NSPR_API(PRStatus) PRP_NakedNotify(PRCondVar *cvar); andre@0: andre@0: /* andre@0: ** Notify all threads waiting on a condition andre@0: ** andre@0: ** Notify the condition specified 'cvar'. andre@0: ** andre@0: ** NB: The CV ('cvar') must be one created using PR_NewNakedCondVar. andre@0: */ andre@0: NSPR_API(PRStatus) PRP_NakedBroadcast(PRCondVar *cvar); andre@0: andre@0: PR_END_EXTERN_C andre@0: andre@0: #endif /* PRPDCE_H */