2015-02-26 15:02:31 +00:00
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
#include <math.h>
|
|
|
|
|
2015-06-01 15:28:29 +00:00
|
|
|
#include "trick/Executive.hh"
|
|
|
|
#include "trick/exec_proto.hh"
|
|
|
|
#include "trick/memorymanager_c_intf.h"
|
|
|
|
#include "trick/TrickConstant.hh"
|
2015-02-26 15:02:31 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
@details
|
|
|
|
*/
|
|
|
|
int Trick::Executive::remove_jobs( Trick::SimObject * in_sim_object ) {
|
|
|
|
|
|
|
|
/* erase jobs from the all_jobs map whose parent_object is this sim_object */
|
|
|
|
for ( std::multimap <std::string, Trick::JobData *>::iterator mit = all_jobs.begin() ; mit != all_jobs.end() ; ) {
|
|
|
|
if ( (*mit).second->parent_object == in_sim_object ) {
|
|
|
|
all_jobs.erase(mit++) ;
|
|
|
|
} else {
|
|
|
|
mit++ ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* erase all jobs from the all_jobs_vector whose parent_object is this sim_object */
|
|
|
|
for ( std::vector <Trick::JobData *>::iterator jit = all_jobs_vector.begin() ; jit != all_jobs_vector.end() ; ) {
|
|
|
|
if ( (*jit)->parent_object == in_sim_object ) {
|
|
|
|
jit = all_jobs_vector.erase(jit) ;
|
|
|
|
} else {
|
|
|
|
jit++ ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* erase all jobs from the all_tagged_jobs map whose parent_object is this sim_object */
|
|
|
|
for ( std::multimap< std::string, Trick::JobData * >::iterator mit = all_tagged_jobs.begin() ; mit != all_tagged_jobs.end() ; ) {
|
|
|
|
if ( (*mit).second->parent_object == in_sim_object ) {
|
|
|
|
all_tagged_jobs.erase(mit++) ;
|
|
|
|
} else {
|
|
|
|
mit++ ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* search the executive queues for the job and remove it if found */
|
2024-04-18 16:41:35 +00:00
|
|
|
for ( std::vector <Trick::JobData *>::iterator jit = in_sim_object->jobs.begin() ; jit != in_sim_object->jobs.end() ; ++jit ) {
|
2015-02-26 15:02:31 +00:00
|
|
|
std::map<std::string, int>::iterator class_id_it ;
|
|
|
|
std::map<int, Trick::ScheduledJobQueue *>::iterator queue_it ;
|
|
|
|
Trick::ScheduledJobQueue * curr_queue ;
|
|
|
|
if ( (class_id_it = class_map.find((*jit)->job_class_name)) != class_map.end() ) {
|
|
|
|
if ( (*jit)->thread != 0 ) {
|
|
|
|
/* Add threaded scheduled jobs to the thread scheduled queue */
|
|
|
|
if ( (*jit)->job_class >= scheduled_start_index ) {
|
|
|
|
threads[(*jit)->thread]->job_queue.remove((*jit)) ;
|
|
|
|
// Add all scheduled jobs to the scheduled_queue for use in the multi-threaded loop
|
|
|
|
scheduled_queue.remove((*jit)) ;
|
|
|
|
/* Threaded top_of_frame/end_of_frame jobs go to thread specific queues. */
|
|
|
|
} else if ( ! (*jit)->job_class_name.compare("top_of_frame")) {
|
|
|
|
threads[(*jit)->thread]->top_of_frame_queue.remove((*jit)) ;
|
|
|
|
} else if ( ! (*jit)->job_class_name.compare("end_of_frame")) {
|
|
|
|
threads[(*jit)->thread]->end_of_frame_queue.remove((*jit)) ;
|
|
|
|
/* Other jobs classes are put into the main thread */
|
|
|
|
} else if ( (queue_it = class_to_queue.find((*jit)->job_class)) != class_to_queue.end() ) {
|
|
|
|
/* for non-scheduled jobs, the class_to_queue map holds the correct queue to insert the job */
|
|
|
|
curr_queue = queue_it->second ;
|
|
|
|
curr_queue->remove( (*jit) ) ;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* if the job is a "scheduled" type job, insert the job into the proper thread queue */
|
|
|
|
if ( (*jit)->job_class >= scheduled_start_index ) {
|
|
|
|
threads[0]->job_queue.remove((*jit)) ;
|
|
|
|
// Add all scheduled jobs to the scheduled_queue for use in the multi-threaded loop
|
|
|
|
scheduled_queue.remove((*jit)) ;
|
|
|
|
} else if ( (queue_it = class_to_queue.find((*jit)->job_class)) != class_to_queue.end() ) {
|
|
|
|
/* for non-scheduled jobs, the class_to_queue map holds the correct queue to insert the job */
|
|
|
|
curr_queue = queue_it->second ;
|
|
|
|
curr_queue->remove( (*jit) ) ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0 ;
|
|
|
|
|
|
|
|
}
|