nsprpub/pr/include/prpdce.h

Fri, 16 Jan 2015 18:13:44 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 18:13:44 +0100
branch
TOR_BUG_9701
changeset 14
925c144e1f1f
permissions
-rw-r--r--

Integrate suggestion from review to improve consistency with existing code.

     1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 /*
     7  * File:		prpdce.h
     8  * Description:	This file is the API defined to allow for DCE (aka POSIX)
     9  *				thread emulation in an NSPR environment. It is not the
    10  *				intent that this be a fully supported API.
    11  */
    13 #if !defined(PRPDCE_H)
    14 #define PRPDCE_H
    16 #include "prlock.h"
    17 #include "prcvar.h"
    18 #include "prtypes.h"
    19 #include "prinrval.h"
    21 PR_BEGIN_EXTERN_C
    23 #define _PR_NAKED_CV_LOCK (PRLock*)0xdce1dce1
    25 /*
    26 ** Test and acquire a lock.
    27 **
    28 ** If the lock is acquired by the calling thread, the
    29 ** return value will be PR_SUCCESS. If the lock is
    30 ** already held, by another thread or this thread, the
    31 ** result will be PR_FAILURE.
    32 */
    33 NSPR_API(PRStatus) PRP_TryLock(PRLock *lock);
    35 /*
    36 ** Create a naked condition variable
    37 **
    38 ** A "naked" condition variable is one that is not created bound
    39 ** to a lock. The CV created with this function is the only type
    40 ** that may be used in the subsequent "naked" condition variable
    41 ** operations (see PRP_NakedWait, PRP_NakedNotify, PRP_NakedBroadcast);
    42 */
    43 NSPR_API(PRCondVar*) PRP_NewNakedCondVar(void);
    45 /*
    46 ** Destroy a naked condition variable
    47 **
    48 ** Destroy the condition variable created by PR_NewNakedCondVar.
    49 */
    50 NSPR_API(void) PRP_DestroyNakedCondVar(PRCondVar *cvar);
    52 /*
    53 ** Wait on a condition
    54 **
    55 ** Wait on the condition variable 'cvar'. It is asserted that
    56 ** the lock protecting the condition 'lock' is held by the
    57 ** calling thread. If more time expires than that declared in
    58 ** 'timeout' the condition will be notified. Waits can be
    59 ** interrupted by another thread.
    60 **
    61 ** NB: The CV ('cvar') must be one created using PR_NewNakedCondVar.
    62 */
    63 NSPR_API(PRStatus) PRP_NakedWait(
    64 	PRCondVar *cvar, PRLock *lock, PRIntervalTime timeout);
    66 /*
    67 ** Notify a thread waiting on a condition
    68 **
    69 ** Notify the condition specified 'cvar'.
    70 **
    71 ** NB: The CV ('cvar') must be one created using PR_NewNakedCondVar.
    72 */
    73 NSPR_API(PRStatus) PRP_NakedNotify(PRCondVar *cvar);
    75 /*
    76 ** Notify all threads waiting on a condition
    77 **
    78 ** Notify the condition specified 'cvar'.
    79 **
    80 ** NB: The CV ('cvar') must be one created using PR_NewNakedCondVar.
    81 */
    82 NSPR_API(PRStatus) PRP_NakedBroadcast(PRCondVar *cvar);
    84 PR_END_EXTERN_C
    86 #endif /* PRPDCE_H */

mercurial