nsprpub/pr/include/pripcsem.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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: pripcsem.h
     8  *
     9  * Description: named semaphores for interprocess
    10  * synchronization
    11  *
    12  * Unrelated processes obtain access to a shared semaphore
    13  * by specifying its name.
    14  *
    15  * Our goal is to support named semaphores on at least
    16  * Unix and Win32 platforms.  The implementation will use
    17  * one of the three native semaphore APIs: POSIX, System V,
    18  * and Win32.
    19  *
    20  * Because POSIX named semaphores have kernel persistence,
    21  * we are forced to have a delete function in this API.
    22  */
    24 #ifndef pripcsem_h___
    25 #define pripcsem_h___
    27 #include "prtypes.h"
    28 #include "prio.h"
    30 PR_BEGIN_EXTERN_C
    32 /*
    33  * PRSem is an opaque structure that represents a named
    34  * semaphore.
    35  */
    36 typedef struct PRSem PRSem;
    38 /*
    39  * PR_OpenSemaphore --
    40  *
    41  * Create or open a named semaphore with the specified name.
    42  * A handle to the semaphore is returned.
    43  *
    44  * If the named semaphore doesn't exist and the PR_SEM_CREATE
    45  * flag is specified, the named semaphore is created.  The
    46  * created semaphore needs to be removed from the system with
    47  * a PR_DeleteSemaphore call.
    48  *
    49  * If PR_SEM_CREATE is specified, the third argument is the
    50  * access permission bits of the new semaphore (same
    51  * interpretation as the mode argument to PR_Open) and the
    52  * fourth argument is the initial value of the new semaphore.
    53  * If PR_SEM_CREATE is not specified, the third and fourth
    54  * arguments are ignored.
    55  */
    57 #define PR_SEM_CREATE 0x1  /* create if not exist */
    58 #define PR_SEM_EXCL   0x2  /* fail if already exists */
    60 NSPR_API(PRSem *) PR_OpenSemaphore(
    61     const char *name, PRIntn flags, PRIntn mode, PRUintn value);
    63 /*
    64  * PR_WaitSemaphore --
    65  *
    66  * If the value of the semaphore is > 0, decrement the value and return.
    67  * If the value is 0, sleep until the value becomes > 0, then decrement
    68  * the value and return.
    69  *
    70  * The "test and decrement" operation is performed atomically.
    71  */
    73 NSPR_API(PRStatus) PR_WaitSemaphore(PRSem *sem);
    75 /*
    76  * PR_PostSemaphore --
    77  *
    78  * Increment the value of the named semaphore by 1.
    79  */
    81 NSPR_API(PRStatus) PR_PostSemaphore(PRSem *sem);
    83 /*
    84  * PR_CloseSemaphore --
    85  *
    86  * Close a named semaphore handle.
    87  */
    89 NSPR_API(PRStatus) PR_CloseSemaphore(PRSem *sem);
    91 /*
    92  * PR_DeleteSemaphore --
    93  *
    94  * Remove a named semaphore from the system.
    95  */
    97 NSPR_API(PRStatus) PR_DeleteSemaphore(const char *name);
    99 PR_END_EXTERN_C
   101 #endif /* pripcsem_h___ */

mercurial