diff --git a/smp/src/abstractIsland.h b/smp/src/abstractIsland.h index db0c4ba2b..fc4bebe98 100644 --- a/smp/src/abstractIsland.h +++ b/smp/src/abstractIsland.h @@ -74,7 +74,7 @@ public: * Update the island by adding population to send in the imigrants list. * @param _data Population to integrate. */ - virtual void update(eoPop _data) = 0; + virtual bool update(eoPop _data) = 0; /** * Check if the algorithm is stopped. diff --git a/smp/src/island.cpp b/smp/src/island.cpp index 544ec51c1..ea3e5ea92 100644 --- a/smp/src/island.cpp +++ b/smp/src/island.cpp @@ -67,7 +67,7 @@ void paradiseo::smp::Island::operator()() stopped = true; // Let's wait the end of communications with the island model for(auto& message : sentMessages) - message.join(); + message.wait(); // Clear the sentMessages container sentMessages.clear(); @@ -125,12 +125,12 @@ void paradiseo::smp::Island::send(eoSelect& _select) // Delete delivered messages sentMessages.erase(std::remove_if(sentMessages.begin(), sentMessages.end(), - [&](std::thread& i) -> bool - { return !i.joinable(); } + [&](std::shared_future& i) -> bool + { return i.wait_for(std::chrono::nanoseconds(0)) == std::future_status::ready; } ), sentMessages.end()); - sentMessages.push_back(std::thread(&IslandModel::update, model, std::move(baseMigPop), this)); + sentMessages.push_back(std::async(std::launch::async, &IslandModel::update, model, std::move(baseMigPop), this)); } } @@ -159,9 +159,11 @@ void paradiseo::smp::Island::receive(void) } template