nsprpub/pr/include/obsolete/prsem.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/nsprpub/pr/include/obsolete/prsem.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,64 @@
     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 +#ifndef prsem_h___
    1.10 +#define prsem_h___
    1.11 +
    1.12 +/*
    1.13 +** API for counting semaphores. Semaphores are counting synchronizing 
    1.14 +** variables based on a lock and a condition variable.  They are lightweight 
    1.15 +** contention control for a given count of resources.
    1.16 +*/
    1.17 +#include "prtypes.h"
    1.18 +
    1.19 +PR_BEGIN_EXTERN_C
    1.20 +
    1.21 +typedef struct PRSemaphore PRSemaphore;
    1.22 +
    1.23 +/*
    1.24 +** Create a new semaphore object.
    1.25 +*/
    1.26 +NSPR_API(PRSemaphore*) PR_NewSem(PRUintn value);
    1.27 +
    1.28 +/*
    1.29 +** Destroy the given semaphore object.
    1.30 +**
    1.31 +*/
    1.32 +NSPR_API(void) PR_DestroySem(PRSemaphore *sem);
    1.33 +
    1.34 +/*
    1.35 +** Wait on a Semaphore.
    1.36 +** 
    1.37 +** This routine allows a calling thread to wait or proceed depending upon the 
    1.38 +** state of the semahore sem. The thread can proceed only if the counter value 
    1.39 +** of the semaphore sem is currently greater than 0. If the value of semaphore 
    1.40 +** sem is positive, it is decremented by one and the routine returns immediately 
    1.41 +** allowing the calling thread to continue. If the value of semaphore sem is 0, 
    1.42 +** the calling thread blocks awaiting the semaphore to be released by another 
    1.43 +** thread.
    1.44 +** 
    1.45 +** This routine can return PR_PENDING_INTERRUPT if the waiting thread 
    1.46 +** has been interrupted.
    1.47 +*/
    1.48 +NSPR_API(PRStatus) PR_WaitSem(PRSemaphore *sem);
    1.49 +
    1.50 +/*
    1.51 +** This routine increments the counter value of the semaphore. If other threads 
    1.52 +** are blocked for the semaphore, then the scheduler will determine which ONE 
    1.53 +** thread will be unblocked.
    1.54 +*/
    1.55 +NSPR_API(void) PR_PostSem(PRSemaphore *sem);
    1.56 +
    1.57 +/*
    1.58 +** Returns the value of the semaphore referenced by sem without affecting
    1.59 +** the state of the semaphore.  The value represents the semaphore vaule
    1.60 +F** at the time of the call, but may not be the actual value when the
    1.61 +** caller inspects it.
    1.62 +*/
    1.63 +NSPR_API(PRUintn) PR_GetValueSem(PRSemaphore *sem);
    1.64 +
    1.65 +PR_END_EXTERN_C
    1.66 +
    1.67 +#endif /* prsem_h___ */

mercurial