| 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/. */ |
| 5 |
|
| 6 |
#ifndef prcmon_h___ |
| 7 |
#define prcmon_h___ |
| 8 |
|
| 9 |
/* |
| 10 |
** Interface to cached monitors. Cached monitors use an address to find a |
| 11 |
** given PR monitor. In this way a monitor can be associated with another |
| 12 |
** object without preallocating a monitor for all objects. |
| 13 |
** |
| 14 |
** A hash table is used to quickly map addresses to individual monitors |
| 15 |
** and the system automatically grows the hash table as needed. |
| 16 |
** |
| 17 |
** Cache monitors are about 5 times slower to use than uncached monitors. |
| 18 |
*/ |
| 19 |
#include "prmon.h" |
| 20 |
#include "prinrval.h" |
| 21 |
|
| 22 |
PR_BEGIN_EXTERN_C |
| 23 |
|
| 24 |
/** |
| 25 |
** Like PR_EnterMonitor except use the "address" to find a monitor in the |
| 26 |
** monitor cache. If successful, returns the PRMonitor now associated |
| 27 |
** with "address". Note that you must PR_CExitMonitor the address to |
| 28 |
** release the monitor cache entry (otherwise the monitor cache will fill |
| 29 |
** up). This call will return NULL if the monitor cache needs to be |
| 30 |
** expanded and the system is out of memory. |
| 31 |
*/ |
| 32 |
NSPR_API(PRMonitor*) PR_CEnterMonitor(void *address); |
| 33 |
|
| 34 |
/* |
| 35 |
** Like PR_ExitMonitor except use the "address" to find a monitor in the |
| 36 |
** monitor cache. |
| 37 |
*/ |
| 38 |
NSPR_API(PRStatus) PR_CExitMonitor(void *address); |
| 39 |
|
| 40 |
/* |
| 41 |
** Like PR_Wait except use the "address" to find a monitor in the |
| 42 |
** monitor cache. |
| 43 |
*/ |
| 44 |
NSPR_API(PRStatus) PR_CWait(void *address, PRIntervalTime timeout); |
| 45 |
|
| 46 |
/* |
| 47 |
** Like PR_Notify except use the "address" to find a monitor in the |
| 48 |
** monitor cache. |
| 49 |
*/ |
| 50 |
NSPR_API(PRStatus) PR_CNotify(void *address); |
| 51 |
|
| 52 |
/* |
| 53 |
** Like PR_NotifyAll except use the "address" to find a monitor in the |
| 54 |
** monitor cache. |
| 55 |
*/ |
| 56 |
NSPR_API(PRStatus) PR_CNotifyAll(void *address); |
| 57 |
|
| 58 |
/* |
| 59 |
** Set a callback to be invoked each time a monitor is recycled from the cache |
| 60 |
** freelist, with the monitor's cache-key passed in address. |
| 61 |
*/ |
| 62 |
NSPR_API(void) PR_CSetOnMonitorRecycle(void (PR_CALLBACK *callback)(void *address)); |
| 63 |
|
| 64 |
PR_END_EXTERN_C |
| 65 |
|
| 66 |
#endif /* prcmon_h___ */ |