Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

80 lines
2.8 KiB

  1. /*==========================================================================
  2. *
  3. * Copyright (C) 1995 - 2000 Microsoft Corporation. All Rights Reserved.
  4. *
  5. * File: fpm.h
  6. * Content: fixed size pool manager
  7. *
  8. * History:
  9. * Date By Reason
  10. * ====== == ======
  11. * 12-18-97 aarono Original
  12. * 11-06-98 ejs Add custom handler for Release function
  13. * 04-12-99 jtk Trimmed unused functions and parameters, added size assert
  14. * 11-22-99 jtk Modified to be .CPP compiliant
  15. * 01-21-2000 jtk Modified to use DNCriticalSections. Added code to check for
  16. * items already being in the pool.
  17. * 11-16/2000 rmt Bug #40587 - DPVOICE: Mixing server needs to use multi-processors
  18. ***************************************************************************/
  19. #ifndef _FPM_H_
  20. #define _FPM_H_
  21. typedef struct FPOOL *PFPOOL, *LPFPOOL;
  22. typedef BOOL (*FN_BLOCKINITALLOC)(void * pvItem);
  23. typedef VOID (*FN_BLOCKINIT)(void * pvItem);
  24. typedef VOID (*FN_BLOCKRELEASE)(void * pvItem);
  25. typedef VOID (*FN_BLOCKFINI)(void *pvItem);
  26. LPFPOOL FPM_Create(
  27. unsigned int size, // size of blocks in pool
  28. FN_BLOCKINITALLOC fnBlockInitAlloc, // fn called for each new alloc
  29. FN_BLOCKINIT fnBlockInit, // fn called each time block used
  30. FN_BLOCKRELEASE fnBlockRelease, // fn called each time block released
  31. FN_BLOCKFINI fnBlockFini, // fn called before releasing mem
  32. DWORD *pdwOutstandingItems = NULL,
  33. DWORD *pdwTotalItems = NULL
  34. );
  35. BOOL FPM_Initialize( LPFPOOL pPool, // pointer to pool to initialize
  36. DWORD dwElementSize, // size of blocks in pool
  37. FN_BLOCKINITALLOC fnBlockInitAlloc, // fn called for each new alloc
  38. FN_BLOCKINIT fnBlockInit, // fn called each time block used
  39. FN_BLOCKRELEASE fnBlockRelease, // fn called each time block released
  40. FN_BLOCKFINI fnBlockFini, // fn called before releasing mem
  41. DWORD *pdwOutstandingItems = NULL, // Memory location to write statistics to
  42. DWORD *pdwTotalItems = NULL // Memory location to write statistics to
  43. );
  44. void FPM_Deinitialize( LPFPOOL pPool, BOOL fAssertOnLeak = TRUE );
  45. typedef void * (*FPM_GET)(LPFPOOL pPool); // get new item from pool
  46. typedef void (*FPM_RELEASE)(LPFPOOL pPool, void *pvItem); // return item to pool
  47. typedef void (*FPM_FINI)(LPFPOOL pPool, BOOL fAssertOnLeak = TRUE); // close pool (this frees the pPool parameter!)
  48. typedef struct FPOOL {
  49. // external
  50. FPM_GET Get;
  51. FPM_RELEASE Release;
  52. FPM_FINI Fini;
  53. // internal
  54. FN_BLOCKINITALLOC fnBlockInitAlloc;
  55. FN_BLOCKINIT fnBlockInit;
  56. FN_BLOCKRELEASE fnBlockRelease;
  57. FN_BLOCKFINI fnBlockFini;
  58. int cbItemSize;
  59. void *pPoolElements;
  60. int nAllocated;
  61. int nInUse;
  62. DNCRITICAL_SECTION cs;
  63. DWORD *pdwOutstandingItems;
  64. DWORD *pdwTotalItems;
  65. } FPOOL, *LPFPOOL, *PFPOOL;
  66. #endif // _FPM_H_