Fri, 16 Jan 2015 04:50:19 +0100
Replace accessor implementation with direct member state manipulation, by
request https://trac.torproject.org/projects/tor/ticket/9701#comment:32
michael@0 | 1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #ifndef prcmon_h___ |
michael@0 | 7 | #define prcmon_h___ |
michael@0 | 8 | |
michael@0 | 9 | /* |
michael@0 | 10 | ** Interface to cached monitors. Cached monitors use an address to find a |
michael@0 | 11 | ** given PR monitor. In this way a monitor can be associated with another |
michael@0 | 12 | ** object without preallocating a monitor for all objects. |
michael@0 | 13 | ** |
michael@0 | 14 | ** A hash table is used to quickly map addresses to individual monitors |
michael@0 | 15 | ** and the system automatically grows the hash table as needed. |
michael@0 | 16 | ** |
michael@0 | 17 | ** Cache monitors are about 5 times slower to use than uncached monitors. |
michael@0 | 18 | */ |
michael@0 | 19 | #include "prmon.h" |
michael@0 | 20 | #include "prinrval.h" |
michael@0 | 21 | |
michael@0 | 22 | PR_BEGIN_EXTERN_C |
michael@0 | 23 | |
michael@0 | 24 | /** |
michael@0 | 25 | ** Like PR_EnterMonitor except use the "address" to find a monitor in the |
michael@0 | 26 | ** monitor cache. If successful, returns the PRMonitor now associated |
michael@0 | 27 | ** with "address". Note that you must PR_CExitMonitor the address to |
michael@0 | 28 | ** release the monitor cache entry (otherwise the monitor cache will fill |
michael@0 | 29 | ** up). This call will return NULL if the monitor cache needs to be |
michael@0 | 30 | ** expanded and the system is out of memory. |
michael@0 | 31 | */ |
michael@0 | 32 | NSPR_API(PRMonitor*) PR_CEnterMonitor(void *address); |
michael@0 | 33 | |
michael@0 | 34 | /* |
michael@0 | 35 | ** Like PR_ExitMonitor except use the "address" to find a monitor in the |
michael@0 | 36 | ** monitor cache. |
michael@0 | 37 | */ |
michael@0 | 38 | NSPR_API(PRStatus) PR_CExitMonitor(void *address); |
michael@0 | 39 | |
michael@0 | 40 | /* |
michael@0 | 41 | ** Like PR_Wait except use the "address" to find a monitor in the |
michael@0 | 42 | ** monitor cache. |
michael@0 | 43 | */ |
michael@0 | 44 | NSPR_API(PRStatus) PR_CWait(void *address, PRIntervalTime timeout); |
michael@0 | 45 | |
michael@0 | 46 | /* |
michael@0 | 47 | ** Like PR_Notify except use the "address" to find a monitor in the |
michael@0 | 48 | ** monitor cache. |
michael@0 | 49 | */ |
michael@0 | 50 | NSPR_API(PRStatus) PR_CNotify(void *address); |
michael@0 | 51 | |
michael@0 | 52 | /* |
michael@0 | 53 | ** Like PR_NotifyAll except use the "address" to find a monitor in the |
michael@0 | 54 | ** monitor cache. |
michael@0 | 55 | */ |
michael@0 | 56 | NSPR_API(PRStatus) PR_CNotifyAll(void *address); |
michael@0 | 57 | |
michael@0 | 58 | /* |
michael@0 | 59 | ** Set a callback to be invoked each time a monitor is recycled from the cache |
michael@0 | 60 | ** freelist, with the monitor's cache-key passed in address. |
michael@0 | 61 | */ |
michael@0 | 62 | NSPR_API(void) PR_CSetOnMonitorRecycle(void (PR_CALLBACK *callback)(void *address)); |
michael@0 | 63 | |
michael@0 | 64 | PR_END_EXTERN_C |
michael@0 | 65 | |
michael@0 | 66 | #endif /* prcmon_h___ */ |