michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef prcmon_h___ michael@0: #define prcmon_h___ michael@0: michael@0: /* michael@0: ** Interface to cached monitors. Cached monitors use an address to find a michael@0: ** given PR monitor. In this way a monitor can be associated with another michael@0: ** object without preallocating a monitor for all objects. michael@0: ** michael@0: ** A hash table is used to quickly map addresses to individual monitors michael@0: ** and the system automatically grows the hash table as needed. michael@0: ** michael@0: ** Cache monitors are about 5 times slower to use than uncached monitors. michael@0: */ michael@0: #include "prmon.h" michael@0: #include "prinrval.h" michael@0: michael@0: PR_BEGIN_EXTERN_C michael@0: michael@0: /** michael@0: ** Like PR_EnterMonitor except use the "address" to find a monitor in the michael@0: ** monitor cache. If successful, returns the PRMonitor now associated michael@0: ** with "address". Note that you must PR_CExitMonitor the address to michael@0: ** release the monitor cache entry (otherwise the monitor cache will fill michael@0: ** up). This call will return NULL if the monitor cache needs to be michael@0: ** expanded and the system is out of memory. michael@0: */ michael@0: NSPR_API(PRMonitor*) PR_CEnterMonitor(void *address); michael@0: michael@0: /* michael@0: ** Like PR_ExitMonitor except use the "address" to find a monitor in the michael@0: ** monitor cache. michael@0: */ michael@0: NSPR_API(PRStatus) PR_CExitMonitor(void *address); michael@0: michael@0: /* michael@0: ** Like PR_Wait except use the "address" to find a monitor in the michael@0: ** monitor cache. michael@0: */ michael@0: NSPR_API(PRStatus) PR_CWait(void *address, PRIntervalTime timeout); michael@0: michael@0: /* michael@0: ** Like PR_Notify except use the "address" to find a monitor in the michael@0: ** monitor cache. michael@0: */ michael@0: NSPR_API(PRStatus) PR_CNotify(void *address); michael@0: michael@0: /* michael@0: ** Like PR_NotifyAll except use the "address" to find a monitor in the michael@0: ** monitor cache. michael@0: */ michael@0: NSPR_API(PRStatus) PR_CNotifyAll(void *address); michael@0: michael@0: /* michael@0: ** Set a callback to be invoked each time a monitor is recycled from the cache michael@0: ** freelist, with the monitor's cache-key passed in address. michael@0: */ michael@0: NSPR_API(void) PR_CSetOnMonitorRecycle(void (PR_CALLBACK *callback)(void *address)); michael@0: michael@0: PR_END_EXTERN_C michael@0: michael@0: #endif /* prcmon_h___ */