From e2f74ab830635b6d0f643a4212b874526354f90c Mon Sep 17 00:00:00 2001 From: David Parsons <david.parsons@inria.fr> Date: Thu, 7 Dec 2023 16:40:38 +0100 Subject: [PATCH] reformat DnaFactory.h --- src/libaevol/7/DnaFactory.h | 111 ++++++++++++++++++------------------ 1 file changed, 56 insertions(+), 55 deletions(-) diff --git a/src/libaevol/7/DnaFactory.h b/src/libaevol/7/DnaFactory.h index 540efe0e5..561085dcb 100644 --- a/src/libaevol/7/DnaFactory.h +++ b/src/libaevol/7/DnaFactory.h @@ -33,76 +33,77 @@ #include <vector> namespace aevol { - enum DnaFactory_Policy { - FIRST = 0, - FIRSTFIT = 1, - BESTFIT = 2, - LOCAL_GLOBAL_FIT = 3, - ALLOCATE = 4 - }; - enum DnaFactory_Garbage_Policy { - MAXSIZE = 0, - MAXMEM = 1 - }; +enum DnaFactory_Policy { + FIRST = 0, + FIRSTFIT = 1, + BESTFIT = 2, + LOCAL_GLOBAL_FIT = 3, + ALLOCATE = 4 +}; - class ExpManager_7; +enum DnaFactory_Garbage_Policy { + MAXSIZE = 0, + MAXMEM = 1 +}; - class DnaFactory { - public: - DnaFactory(DnaFactory_Policy policy, int pool_size, int init_size, int pop_size = -1) { - policy_ = policy; - pool_size_ = pool_size; - // printf("Pool init \n"); - init(init_size,pop_size); - } +class ExpManager_7; - ~DnaFactory() { - for (auto&& it_dna : list_unused_dna_) { - delete it_dna; - } - list_unused_dna_.clear(); +class DnaFactory { + public: + DnaFactory(DnaFactory_Policy policy, int pool_size, int init_size, int pop_size = -1) { + policy_ = policy; + pool_size_ = pool_size; + // printf("Pool init \n"); + init(init_size, pop_size); + } - for (size_t j = 0; j < local_list_unused_dna_.size(); j++) { - for (auto&& it_dna : local_list_unused_dna_[j]) { - delete it_dna; - } - local_list_unused_dna_[j].clear(); - } - local_list_unused_dna_.clear(); + ~DnaFactory() { + for (auto &&it_dna: list_unused_dna_) { + delete it_dna; + } + list_unused_dna_.clear(); - } + for (size_t j = 0; j < local_list_unused_dna_.size(); j++) { + for (auto &&it_dna: local_list_unused_dna_[j]) { + delete it_dna; + } + local_list_unused_dna_[j].clear(); + } + local_list_unused_dna_.clear(); + } - void init(int init_size, int pop_size = -1); + void init(int init_size, int pop_size = -1); - Dna_7 *get_dna(int request_size); + Dna_7 *get_dna(int request_size); - void give_back(Dna_7 *dna); + void give_back(Dna_7 *dna); - void reduce_space(ExpManager_7* exp_m); + void reduce_space(ExpManager_7 *exp_m); - const static int32_t cleanup_step = 100; + const static int32_t cleanup_step = 100; - const static DnaFactory_Garbage_Policy garbage_policy = DnaFactory_Garbage_Policy::MAXMEM; + const static DnaFactory_Garbage_Policy garbage_policy = DnaFactory_Garbage_Policy::MAXMEM; - private: - std::list<Dna_7 *> list_unused_dna_; - std::vector<std::list<Dna_7 *>> local_list_unused_dna_; - DnaFactory_Policy policy_; - int pool_size_; + private: + std::list<Dna_7 *> list_unused_dna_; + std::vector<std::list<Dna_7 *>> local_list_unused_dna_; + DnaFactory_Policy policy_; + int pool_size_; - int global_pool_size_ = 256; - size_t local_pool_size_ = 256; + int global_pool_size_ = 256; + size_t local_pool_size_ = 256; - size_t max_pool_size = 16000; + size_t max_pool_size = 16000; - // int empty_global = 0; - // int local_empty = 0; + // int empty_global = 0; + // int local_empty = 0; - // int free_space_local = 0; - // int free_local = 0; - // int free_global = 0; - }; + // int free_space_local = 0; + // int free_local = 0; + // int free_global = 0; +}; -} -#endif //AEVOL_DNAFACTORY_H +} // namespace aevol + +#endif //AEVOL_DNAFACTORY_H -- GitLab