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.

62 lines
1.0 KiB

  1. /*++
  2. Copyright (C) Microsoft Corporation, 1996 - 1999
  3. Module Name:
  4. hndlcach.hxx
  5. Abstract:
  6. The handle cache.
  7. Author:
  8. Kamen Moutafov [KamenM]
  9. Revision History:
  10. --*/
  11. #ifndef __HNDLCACH_HXX
  12. #define __HNDLCACH_HXX
  13. const INT DEFAULT_CACHE_SIZE = 2;
  14. class HandleCache
  15. {
  16. public:
  17. inline HandleCache(void)
  18. {
  19. Init();
  20. }
  21. ~HandleCache(void);
  22. inline void Init(void)
  23. {
  24. int i;
  25. for (i = 0; i < DEFAULT_CACHE_SIZE; i ++)
  26. {
  27. cacheSlots[i] = NULL;
  28. }
  29. }
  30. // not synchronized
  31. HANDLE CheckOutHandle(void);
  32. // synchronized between multiple threads. Will zero out the handle if it
  33. // was saved in the cache. If the cache is empty, this call has defined
  34. // FIFO semantics. This is significant in the NPFS case.
  35. void CheckinHandle(HANDLE *ph);
  36. #if defined(DBG) || defined(_DEBUG)
  37. // not synchornized
  38. BOOL IsSecondHandleUsed(void);
  39. #endif
  40. private:
  41. HANDLE cacheSlots[DEFAULT_CACHE_SIZE];
  42. };
  43. #endif // __HNDLCACH_HXX