Fix critical memory issue. Sent messages are launched asynchronously and only -std::future- results are stocked. This enable to check if a thread has completed its task (update methods in Model and Island return always true in that purpose) unlike the std:🧵:joinable method.

This commit is contained in:
quemy 2013-02-20 01:51:38 +01:00
commit ca44e95add
5 changed files with 25 additions and 13 deletions

View file

@ -33,6 +33,7 @@ Contact: paradiseo-help@lists.gforge.inria.fr
#include <queue>
#include <algorithm>
#include <utility>
#include <future>
#include <thread>
#include <bimap.h>
@ -71,7 +72,7 @@ public:
/**
* Update the island model by adding population to send in the emigrants list.
*/
void update(eoPop<EOT> _data, AIsland<EOT>* _island);
bool update(eoPop<EOT> _data, AIsland<EOT>* _island);
/**
* Change topology
@ -99,7 +100,7 @@ protected:
Bimap<unsigned, AIsland<EOT>*> table;
std::vector<std::pair<AIsland<EOT>*, bool>> islands;
AbstractTopology& topo;
std::vector<std::thread> sentMessages;
std::vector<std::shared_future<bool>> sentMessages;
std::mutex m;
std::atomic<bool> running;
};