Backed out changeset b71c8c052463 (bug 1943846) for causing mass failures. CLOSED...
[gecko.git] / nsprpub / pr / include / prcmon.h
blob69171138b278cfab51fb299ea17fca48a051578a
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 #ifndef prcmon_h___
7 #define prcmon_h___
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.
14 ** A hash table is used to quickly map addresses to individual monitors
15 ** and the system automatically grows the hash table as needed.
17 ** Cache monitors are about 5 times slower to use than uncached monitors.
19 #include "prmon.h"
20 #include "prinrval.h"
22 PR_BEGIN_EXTERN_C
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.
32 NSPR_API(PRMonitor*) PR_CEnterMonitor(void *address);
35 ** Like PR_ExitMonitor except use the "address" to find a monitor in the
36 ** monitor cache.
38 NSPR_API(PRStatus) PR_CExitMonitor(void *address);
41 ** Like PR_Wait except use the "address" to find a monitor in the
42 ** monitor cache.
44 NSPR_API(PRStatus) PR_CWait(void *address, PRIntervalTime timeout);
47 ** Like PR_Notify except use the "address" to find a monitor in the
48 ** monitor cache.
50 NSPR_API(PRStatus) PR_CNotify(void *address);
53 ** Like PR_NotifyAll except use the "address" to find a monitor in the
54 ** monitor cache.
56 NSPR_API(PRStatus) PR_CNotifyAll(void *address);
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.
62 NSPR_API(void) PR_CSetOnMonitorRecycle(void (PR_CALLBACK *callback)(void *address));
64 PR_END_EXTERN_C
66 #endif /* prcmon_h___ */