MPI job functors have to be created with new, so as to be deleted by delete, because of Composite / Decorator pattern.

This commit is contained in:
Benjamin Bouvier 2012-07-10 17:34:18 +02:00
commit 472b86bc68
3 changed files with 12 additions and 45 deletions

View file

@ -119,6 +119,7 @@ namespace eo
template< typename JobData >
struct JobStore
{
// TODO commentaire: ces pointeurs devraient être alloués avec new pour éviter segfault on quit.
JobStore(
SendTaskFunction<JobData>* stf,
HandleResponseFunction<JobData>* hrf,
@ -135,6 +136,16 @@ namespace eo
// empty
}
~JobStore()
{
// TODO commentaire: Composition Pattern => délégation de la destruction => destruction homogène => new
// et delete partout.
delete _stf;
delete _hrf;
delete _ptf;
delete _iff;
}
SendTaskFunction<JobData> & sendTask() { return *_stf; }
HandleResponseFunction<JobData> & handleResponse() { return *_hrf; }
ProcessTaskFunction<JobData> & processTask() { return *_ptf; }
@ -377,7 +388,7 @@ namespace eo
AssignmentAlgorithm& assignmentAlgo;
int masterRank;
const int workerStopCondition;
const int workerStopCondition; // TODO commentaire: message signifiant l'arrêt pour un worker
bmpi::communicator& comm;
SendTaskFunction<JobData> & sendTask;

View file

@ -194,10 +194,6 @@ namespace eo
virtual ~ParallelApplyStore()
{
delete _stf;
delete _hrf;
delete _ptf;
delete _iff;
}
protected:

View file

@ -54,14 +54,6 @@ namespace eo
_iff = new DummyIsFinishedFunction;
}
~DummyJobStore()
{
delete _stf;
delete _hrf;
delete _ptf;
delete _iff;
}
void* data() { return 0; }
};
@ -83,38 +75,6 @@ namespace eo
}
}
};
/*
class TerminateJob : public Job
{
public:
TerminateJob( AssignmentAlgorithm& algo, int _ )
: Job( algo, _ )
{
// empty
}
void sendTask( int wrkRank )
{
// empty
}
void handleResponse( int wrkRank )
{
// empty
}
void processTask( )
{
// empty
}
bool isFinished()
{
return true;
}
};
*/
}
}