ECTPropsPurge.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. * Copyright 2005 - 2016 Zarafa and its licensors
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU Affero General Public License, version 3,
  6. * as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU Affero General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU Affero General Public License
  14. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. *
  16. */
  17. #ifndef ECTPROPSPURGE_H
  18. #define ECTPROPSPURGE_H
  19. #include <kopano/zcdefs.h>
  20. #include <mutex>
  21. #include <pthread.h>
  22. namespace KC {
  23. class ECDatabase;
  24. class ECConfig;
  25. class ECDatabaseFactory;
  26. class ECSession;
  27. class ECTPropsPurge _kc_final {
  28. public:
  29. ECTPropsPurge(ECConfig *lpConfig, ECDatabaseFactory *lpDatabaseFactory);
  30. ~ECTPropsPurge();
  31. static ECRESULT PurgeDeferredTableUpdates(ECDatabase *lpDatabase, unsigned int ulFolderId);
  32. static ECRESULT GetDeferredCount(ECDatabase *lpDatabase, unsigned int *lpulCount);
  33. static ECRESULT GetLargestFolderId(ECDatabase *lpDatabase, unsigned int *lpulFolderId);
  34. static ECRESULT AddDeferredUpdate(ECSession *lpSession, ECDatabase *lpDatabase, unsigned int ulFolderId, unsigned int ulOldFolderId, unsigned int ulObjId);
  35. static ECRESULT AddDeferredUpdateNoPurge(ECDatabase *lpDatabase, unsigned int ulFolderId, unsigned int ulOldFolderId, unsigned int ulObjId);
  36. static ECRESULT NormalizeDeferredUpdates(ECSession *lpSession, ECDatabase *lpDatabase, unsigned int ulFolderId);
  37. private:
  38. ECRESULT PurgeThread();
  39. ECRESULT PurgeOverflowDeferred(ECDatabase *lpDatabase);
  40. static ECRESULT GetDeferredCount(ECDatabase *lpDatabase, unsigned int ulFolderId, unsigned int *lpulCount);
  41. static void *Thread(void *param);
  42. std::mutex m_hMutexExit;
  43. std::condition_variable m_hCondExit;
  44. pthread_t m_hThread;
  45. bool m_bExit = false;
  46. ECConfig *m_lpConfig;
  47. ECDatabaseFactory *m_lpDatabaseFactory;
  48. };
  49. } /* namespace */
  50. #endif