Avoid race condition by manualy setting the island statut on running (Nils Mangelsen)
This commit is contained in:
parent
d41cbbe781
commit
c9c982fb81
4 changed files with 18 additions and 1 deletions
|
|
@ -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.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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++;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue