Leaked source code of windows server 2003
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.

44 lines
1.4 KiB

  1. //
  2. // txtcache.h
  3. //
  4. #ifndef TXTCACHE_H
  5. #define TXTCACHE_H
  6. #define CACHE_SIZE_TEXT 128
  7. #define CACHE_PRELOAD_COUNT (CACHE_SIZE_TEXT/4) // number of chars we ask for ahead of the GetText acpStart to init the cache
  8. #define CACHE_SIZE_RUNINFO (CACHE_PRELOAD_COUNT+1) // this number should be very small for speed, but must be > CACHE_PRELOAD_COUNT
  9. // the danger is that we could run out of space before hitting the caller's acpStart
  10. class CProcessTextCache
  11. {
  12. public:
  13. static HRESULT GetText(ITextStoreACP *ptsi, LONG acpStart, LONG acpEnd,
  14. WCHAR *pchPlain, ULONG cchPlainReq, ULONG *pcchPlainOut,
  15. TS_RUNINFO *prgRunInfo, ULONG ulRunInfoReq, ULONG *pulRunInfoOut,
  16. LONG *pacpNext);
  17. static void Invalidate(ITextStoreACP *ptsi)
  18. {
  19. // not strictly thread safe
  20. // BUT, since we're appartment threaded, we shouldn't ever invalidate the
  21. // same ptsi that someone is trying to use simultaneously
  22. if (_ptsi == ptsi)
  23. {
  24. _ptsi = NULL;
  25. }
  26. }
  27. private:
  28. static long _lCacheMutex;
  29. static ITextStoreACP *_ptsi;
  30. static LONG _acpStart;
  31. static LONG _acpEnd;
  32. static WCHAR _achPlain[CACHE_SIZE_TEXT];
  33. static TS_RUNINFO _rgRunInfo[CACHE_SIZE_RUNINFO];
  34. static ULONG _ulRunInfoLen;
  35. };
  36. #endif // TXTCACHE_H