diff options
author | Jacob Keeler <jacob.keeler@livioradio.com> | 2019-10-28 13:31:06 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-28 13:31:06 -0400 |
commit | ce1a797036355da13a3f45262f0ec348af311437 (patch) | |
tree | 12de441fb7dcfc5e999e8450864993dcdb8291b7 /src/components/policy/policy_external/include/policy/cache_manager.h | |
parent | 9323de6c181cd461ac0f392965c3ae7da12a4646 (diff) | |
parent | 32d697135fa021d2cf45366d4ebf0ac9e941accd (diff) | |
download | sdl_core-ce1a797036355da13a3f45262f0ec348af311437.tar.gz |
Merge pull request #3099 from smartdevicelink/fix/fix_synchronize_backup_and_reset_functions_in_cache
Synchronize backup and reset policy functions
Diffstat (limited to 'src/components/policy/policy_external/include/policy/cache_manager.h')
-rw-r--r-- | src/components/policy/policy_external/include/policy/cache_manager.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/components/policy/policy_external/include/policy/cache_manager.h b/src/components/policy/policy_external/include/policy/cache_manager.h index 1bac72e2c6..5e3cf3dde7 100644 --- a/src/components/policy/policy_external/include/policy/cache_manager.h +++ b/src/components/policy/policy_external/include/policy/cache_manager.h @@ -33,6 +33,7 @@ #ifndef SRC_COMPONENTS_POLICY_POLICY_EXTERNAL_INCLUDE_POLICY_CACHE_MANAGER_H_ #define SRC_COMPONENTS_POLICY_POLICY_EXTERNAL_INCLUDE_POLICY_CACHE_MANAGER_H_ +#include <atomic> #include <map> #include "boost/optional.hpp" @@ -1129,12 +1130,28 @@ class CacheManager : public CacheManagerInterface { ~BackgroundBackuper(); virtual void threadMain(); virtual void exitThreadMain(); + + /** + * @brief Notifies BackgroundBackuper thread that new data is available and + * new backup iteration should be scheduled + */ void DoBackup(); + /** + * @brief Waits for BackgroundBackuper thread finish its own backup + * iteration. If currently no backup iteration in progress - function just + * returns the control back + */ + void WaitForBackupIsDone(); + private: void InternalBackup(); CacheManager* cache_manager_; sync_primitives::ConditionalVariable backup_notifier_; + sync_primitives::ConditionalVariable backup_done_; + sync_primitives::Lock backup_done_lock_; + + std::atomic_bool backup_is_in_progress_; volatile bool stop_flag_; volatile bool new_data_available_; |