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

@ -34,6 +34,7 @@ Contact: paradiseo-help@lists.gforge.inria.fr
#include <vector>
#include <utility>
#include <atomic>
#include <future>
#include <type_traits>
#include <algorithm>
@ -113,7 +114,7 @@ public:
* Update the list of imigrants.
* @param _data Elements to integrate in the main population.
*/
void update(eoPop<bEOT> _data);
bool update(eoPop<bEOT> _data);
/**
* Check if the algorithm is stopped.
@ -148,7 +149,7 @@ protected:
IntPolicy<EOT>& intPolicy;
MigPolicy<EOT>& migPolicy;
std::atomic<bool> stopped;
std::vector<std::thread> sentMessages;
std::vector<std::shared_future<bool>> sentMessages;
IslandModel<bEOT>* model;
std::function<EOT(bEOT&)> convertFromBase;
std::function<bEOT(EOT&)> convertToBase;