diff --git a/eo/src/mpi/eoMpi.h b/eo/src/mpi/eoMpi.h index 0ef80c12..8521d5c3 100644 --- a/eo/src/mpi/eoMpi.h +++ b/eo/src/mpi/eoMpi.h @@ -199,10 +199,12 @@ namespace eo public: Job( AssignmentAlgorithm& _algo, int _masterRank, + int _workerStopCondition, JobStore & store ) : assignmentAlgo( _algo ), masterRank( _masterRank ), + workerStopCondition( _workerStopCondition ), comm( Node::comm() ), // Functors sendTask( store.sendTask() ), @@ -339,7 +341,7 @@ namespace eo # ifndef NDEBUG eo::log << "[W" << comm.rank() << "] Waiting for an order..." << std::endl; # endif - if ( order == Message::Kill ) + if ( order == workerStopCondition ) { # ifndef NDEBUG eo::log << "[W" << comm.rank() << "] Leaving worker task." << std::endl; @@ -375,6 +377,7 @@ namespace eo AssignmentAlgorithm& assignmentAlgo; int masterRank; + const int workerStopCondition; bmpi::communicator& comm; SendTaskFunction & sendTask; @@ -383,6 +386,35 @@ namespace eo IsFinishedFunction & isFinished; bool _isMaster; + + }; + + template< class JobData > + class OneShotJob : public Job< JobData > + { + // TODO commentaire : ce job s'arrête sur message terminate + public: + OneShotJob( AssignmentAlgorithm& algo, + int masterRank, + JobStore & store ) + : Job( algo, masterRank, Message::Finish, store ) + { + // empty + } + }; + + template< class JobData > + class MultiJob : public Job< JobData > + { + public: + // TODO commentaire : ce job s'arrête sur message kill + MultiJob ( AssignmentAlgorithm& algo, + int masterRank, + JobStore & store ) + : Job( algo, masterRank, Message::Kill, store ) + { + // empty + } }; } } diff --git a/eo/src/mpi/eoParallelApply.h b/eo/src/mpi/eoParallelApply.h index a0225471..4ef58830 100644 --- a/eo/src/mpi/eoParallelApply.h +++ b/eo/src/mpi/eoParallelApply.h @@ -207,7 +207,7 @@ namespace eo // TODO commentaire : impossible de faire un typedef sur un template sans passer // par un traits => complique la tâche de l'utilisateur pour rien. template< typename EOT > - class ParallelApply : public Job< ParallelApplyData > + class ParallelApply : public MultiJob< ParallelApplyData > { public: @@ -216,7 +216,7 @@ namespace eo int _masterRank, ParallelApplyStore & store ) : - Job< ParallelApplyData >( algo, _masterRank, store ) + MultiJob< ParallelApplyData >( algo, _masterRank, store ) { // empty } diff --git a/eo/src/mpi/eoTerminateJob.h b/eo/src/mpi/eoTerminateJob.h index d85aeeb0..bda085a0 100644 --- a/eo/src/mpi/eoTerminateJob.h +++ b/eo/src/mpi/eoTerminateJob.h @@ -65,10 +65,10 @@ namespace eo void* data() { return 0; } }; - struct EmptyJob : public Job + struct EmptyJob : public OneShotJob { EmptyJob( AssignmentAlgorithm& algo, int masterRank ) : - Job( algo, masterRank, *(new DummyJobStore) ) + OneShotJob( algo, masterRank, *(new DummyJobStore) ) // FIXME memory leak => will be corrected by using const correctness { // empty