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