From ece3c702f6d510a7d9cb9ddee8bfba7ca70d768c Mon Sep 17 00:00:00 2001 From: Pherring04 Date: Wed, 17 Apr 2024 12:28:29 -0500 Subject: [PATCH] Implemented call to clear Monte Carlo job queues when the Executive restarts. --- include/trick/MonteCarlo.hh | 7 +++++++ .../Executive/Executive_restart.cpp | 7 +++++++ .../MonteCarlo/MonteCarlo_clear_job_queues.cpp | 17 +++++++++++++++++ 3 files changed, 31 insertions(+) create mode 100644 trick_source/sim_services/MonteCarlo/MonteCarlo_clear_job_queues.cpp diff --git a/include/trick/MonteCarlo.hh b/include/trick/MonteCarlo.hh index bbdc9b82..c353ba89 100644 --- a/include/trick/MonteCarlo.hh +++ b/include/trick/MonteCarlo.hh @@ -777,6 +777,13 @@ namespace Trick { int write(char* data, int size); int read(char* data, int size); + + /** Reset job queues for checkpoint restart + * + * + */ + void clear_job_queues(); + #if 0 /** Overload default implentation of Scheduler::add_sim_object diff --git a/trick_source/sim_services/Executive/Executive_restart.cpp b/trick_source/sim_services/Executive/Executive_restart.cpp index 7cd6fec3..c8abd8ec 100644 --- a/trick_source/sim_services/Executive/Executive_restart.cpp +++ b/trick_source/sim_services/Executive/Executive_restart.cpp @@ -9,6 +9,9 @@ #include "trick/memorymanager_c_intf.h" #include "trick/ScheduledJobQueue.hh" #include "trick/Threads.hh" +#include "trick/MonteCarlo.hh" + +extern Trick::MonteCarlo *the_mc; /** @details @@ -43,6 +46,10 @@ int Trick::Executive::restart() { all_jobs_vector.clear() ; all_tagged_jobs.clear() ; + if(the_mc) { + the_mc->clear_job_queues(); + } + /* Create a temporary all_jobs map to use to restore job data from all_jobs_for_checkpoint */ for ( sit = sim_objects.begin() ; sit != sim_objects.end() ; sit++ ) { for ( jit = (*sit)->jobs.begin() ; jit != (*sit)->jobs.end() ; jit++ ) { diff --git a/trick_source/sim_services/MonteCarlo/MonteCarlo_clear_job_queues.cpp b/trick_source/sim_services/MonteCarlo/MonteCarlo_clear_job_queues.cpp new file mode 100644 index 00000000..4096ac87 --- /dev/null +++ b/trick_source/sim_services/MonteCarlo/MonteCarlo_clear_job_queues.cpp @@ -0,0 +1,17 @@ + +#include "trick/MonteCarlo.hh" +#include "trick/message_proto.h" +#include "trick/message_type.h" + +void Trick::MonteCarlo::clear_job_queues() { + + master_init_queue.clear(); + master_pre_queue.clear(); + master_post_queue.clear(); + master_shutdown_queue.clear(); + slave_init_queue.clear(); + slave_pre_queue.clear(); + slave_post_queue.clear(); + slave_shutdown_queue.clear(); + +}