Mentions légales du service

Skip to content
Snippets Groups Projects
Commit e2f74ab8 authored by David Parsons's avatar David Parsons
Browse files

reformat DnaFactory.h

parent d9667c38
No related branches found
No related tags found
No related merge requests found
...@@ -33,76 +33,77 @@ ...@@ -33,76 +33,77 @@
#include <vector> #include <vector>
namespace aevol { namespace aevol {
enum DnaFactory_Policy {
FIRST = 0,
FIRSTFIT = 1,
BESTFIT = 2,
LOCAL_GLOBAL_FIT = 3,
ALLOCATE = 4
};
enum DnaFactory_Garbage_Policy { enum DnaFactory_Policy {
MAXSIZE = 0, FIRST = 0,
MAXMEM = 1 FIRSTFIT = 1,
}; BESTFIT = 2,
LOCAL_GLOBAL_FIT = 3,
ALLOCATE = 4
};
class ExpManager_7; enum DnaFactory_Garbage_Policy {
MAXSIZE = 0,
MAXMEM = 1
};
class DnaFactory { class ExpManager_7;
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);
}
~DnaFactory() { class DnaFactory {
for (auto&& it_dna : list_unused_dna_) { public:
delete it_dna; DnaFactory(DnaFactory_Policy policy, int pool_size, int init_size, int pop_size = -1) {
} policy_ = policy;
list_unused_dna_.clear(); 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++) { ~DnaFactory() {
for (auto&& it_dna : local_list_unused_dna_[j]) { for (auto &&it_dna: list_unused_dna_) {
delete it_dna; delete it_dna;
} }
local_list_unused_dna_[j].clear(); list_unused_dna_.clear();
}
local_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: private:
std::list<Dna_7 *> list_unused_dna_; std::list<Dna_7 *> list_unused_dna_;
std::vector<std::list<Dna_7 *>> local_list_unused_dna_; std::vector<std::list<Dna_7 *>> local_list_unused_dna_;
DnaFactory_Policy policy_; DnaFactory_Policy policy_;
int pool_size_; int pool_size_;
int global_pool_size_ = 256; int global_pool_size_ = 256;
size_t local_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 empty_global = 0;
// int local_empty = 0; // int local_empty = 0;
// int free_space_local = 0; // int free_space_local = 0;
// int free_local = 0; // int free_local = 0;
// int free_global = 0; // int free_global = 0;
}; };
} } // namespace aevol
#endif //AEVOL_DNAFACTORY_H
#endif //AEVOL_DNAFACTORY_H
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment