Avoid race condition by manualy setting the island statut on running (Nils Mangelsen)

This commit is contained in:
quemy 2013-02-07 23:18:39 +01:00
commit c9c982fb81
4 changed files with 18 additions and 1 deletions

View file

@ -82,6 +82,11 @@ public:
*/
virtual bool isStopped(void) const = 0;
/**
* Set the stopped indicator on false
*/
virtual void setRunning(void) = 0;
/**
* Receive population by integrate individuals.
*/

View file

@ -103,6 +103,12 @@ bool paradiseo::smp::Island<EOAlgo,EOT,bEOT>::isStopped(void) const
return (bool)stopped;
}
template<template <class> class EOAlgo, class EOT, class bEOT>
void paradiseo::smp::Island<EOAlgo,EOT,bEOT>::setRunning(void)
{
stopped = false;
}
template<template <class> class EOAlgo, class EOT, class bEOT>
void paradiseo::smp::Island<EOAlgo,EOT,bEOT>::send(eoSelect<EOT>& _select)
{

View file

@ -119,7 +119,12 @@ public:
* Check if the algorithm is stopped.
* @return true if stopped
*/
virtual bool isStopped(void) const;
virtual bool isStopped(void) const;
/**
* Set the stopped indicator on false
*/
virtual void setRunning(void);
/**
* Check if there is population to receive

View file

@ -58,6 +58,7 @@ void paradiseo::smp::IslandModel<EOT>::operator()()
unsigned i = 0;
for(auto it : islands)
{
it.first->setRunning();
threads[i] = std::thread(&AIsland<EOT>::operator(), it.first);
i++;
}