1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/nsprpub/pr/include/prcmon.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,66 @@ 1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#ifndef prcmon_h___ 1.10 +#define prcmon_h___ 1.11 + 1.12 +/* 1.13 +** Interface to cached monitors. Cached monitors use an address to find a 1.14 +** given PR monitor. In this way a monitor can be associated with another 1.15 +** object without preallocating a monitor for all objects. 1.16 +** 1.17 +** A hash table is used to quickly map addresses to individual monitors 1.18 +** and the system automatically grows the hash table as needed. 1.19 +** 1.20 +** Cache monitors are about 5 times slower to use than uncached monitors. 1.21 +*/ 1.22 +#include "prmon.h" 1.23 +#include "prinrval.h" 1.24 + 1.25 +PR_BEGIN_EXTERN_C 1.26 + 1.27 +/** 1.28 +** Like PR_EnterMonitor except use the "address" to find a monitor in the 1.29 +** monitor cache. If successful, returns the PRMonitor now associated 1.30 +** with "address". Note that you must PR_CExitMonitor the address to 1.31 +** release the monitor cache entry (otherwise the monitor cache will fill 1.32 +** up). This call will return NULL if the monitor cache needs to be 1.33 +** expanded and the system is out of memory. 1.34 +*/ 1.35 +NSPR_API(PRMonitor*) PR_CEnterMonitor(void *address); 1.36 + 1.37 +/* 1.38 +** Like PR_ExitMonitor except use the "address" to find a monitor in the 1.39 +** monitor cache. 1.40 +*/ 1.41 +NSPR_API(PRStatus) PR_CExitMonitor(void *address); 1.42 + 1.43 +/* 1.44 +** Like PR_Wait except use the "address" to find a monitor in the 1.45 +** monitor cache. 1.46 +*/ 1.47 +NSPR_API(PRStatus) PR_CWait(void *address, PRIntervalTime timeout); 1.48 + 1.49 +/* 1.50 +** Like PR_Notify except use the "address" to find a monitor in the 1.51 +** monitor cache. 1.52 +*/ 1.53 +NSPR_API(PRStatus) PR_CNotify(void *address); 1.54 + 1.55 +/* 1.56 +** Like PR_NotifyAll except use the "address" to find a monitor in the 1.57 +** monitor cache. 1.58 +*/ 1.59 +NSPR_API(PRStatus) PR_CNotifyAll(void *address); 1.60 + 1.61 +/* 1.62 +** Set a callback to be invoked each time a monitor is recycled from the cache 1.63 +** freelist, with the monitor's cache-key passed in address. 1.64 +*/ 1.65 +NSPR_API(void) PR_CSetOnMonitorRecycle(void (PR_CALLBACK *callback)(void *address)); 1.66 + 1.67 +PR_END_EXTERN_C 1.68 + 1.69 +#endif /* prcmon_h___ */