prcmon.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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/. */
  5. #ifndef prcmon_h___
  6. #define prcmon_h___
  7. /*
  8. ** Interface to cached monitors. Cached monitors use an address to find a
  9. ** given PR monitor. In this way a monitor can be associated with another
  10. ** object without preallocating a monitor for all objects.
  11. **
  12. ** A hash table is used to quickly map addresses to individual monitors
  13. ** and the system automatically grows the hash table as needed.
  14. **
  15. ** Cache monitors are about 5 times slower to use than uncached monitors.
  16. */
  17. #include "prmon.h"
  18. #include "prinrval.h"
  19. PR_BEGIN_EXTERN_C
  20. /**
  21. ** Like PR_EnterMonitor except use the "address" to find a monitor in the
  22. ** monitor cache. If successful, returns the PRMonitor now associated
  23. ** with "address". Note that you must PR_CExitMonitor the address to
  24. ** release the monitor cache entry (otherwise the monitor cache will fill
  25. ** up). This call will return NULL if the monitor cache needs to be
  26. ** expanded and the system is out of memory.
  27. */
  28. NSPR_API(PRMonitor*) PR_CEnterMonitor(void *address);
  29. /*
  30. ** Like PR_ExitMonitor except use the "address" to find a monitor in the
  31. ** monitor cache.
  32. */
  33. NSPR_API(PRStatus) PR_CExitMonitor(void *address);
  34. /*
  35. ** Like PR_Wait except use the "address" to find a monitor in the
  36. ** monitor cache.
  37. */
  38. NSPR_API(PRStatus) PR_CWait(void *address, PRIntervalTime timeout);
  39. /*
  40. ** Like PR_Notify except use the "address" to find a monitor in the
  41. ** monitor cache.
  42. */
  43. NSPR_API(PRStatus) PR_CNotify(void *address);
  44. /*
  45. ** Like PR_NotifyAll except use the "address" to find a monitor in the
  46. ** monitor cache.
  47. */
  48. NSPR_API(PRStatus) PR_CNotifyAll(void *address);
  49. /*
  50. ** Set a callback to be invoked each time a monitor is recycled from the cache
  51. ** freelist, with the monitor's cache-key passed in address.
  52. */
  53. NSPR_API(void) PR_CSetOnMonitorRecycle(void (PR_CALLBACK *callback)(void *address));
  54. PR_END_EXTERN_C
  55. #endif /* prcmon_h___ */