mirror of
https://github.com/nasa/trick.git
synced 2024-12-21 06:03:10 +00:00
1afac18399
Created a thread trigger container class to hold all of the various thread triggering mechanisms. I wanted to avoid allocating/freeing trigger mechanisms. I added an eventfd and futex trigger types. Updated SIM_threads_simple test sim to use show how to set the thread trigger type. refs #148
52 lines
1.4 KiB
C++
52 lines
1.4 KiB
C++
|
|
#include <iostream>
|
|
#include <sstream>
|
|
#include <stdio.h>
|
|
|
|
#include "trick/Threads.hh"
|
|
|
|
Trick::Threads::Threads(int in_id , bool in_rt_nap) :
|
|
enabled(true) ,
|
|
thread_id(in_id) ,
|
|
curr_time_tics(0) ,
|
|
amf_cycle(0.0) ,
|
|
amf_cycle_tics(0) ,
|
|
amf_next_tics(0) ,
|
|
curr_job(NULL) ,
|
|
rt_nap(in_rt_nap) ,
|
|
process_type(PROCESS_TYPE_SCHEDULED) ,
|
|
child_complete(false) ,
|
|
running(false) ,
|
|
shutdown_wait_async(false) {
|
|
std::stringstream oss ;
|
|
oss << "Child_" << in_id ;
|
|
name = oss.str() ;
|
|
}
|
|
|
|
void Trick::Threads::set_pthread_id(pthread_t in_pthread_id) {
|
|
pthread_id = in_pthread_id ;
|
|
}
|
|
|
|
void Trick::Threads::set_enabled( bool in_enabled ) {
|
|
enabled = in_enabled ;
|
|
}
|
|
|
|
void Trick::Threads::clear_scheduled_queues() {
|
|
job_queue.clear() ;
|
|
top_of_frame_queue.clear() ;
|
|
end_of_frame_queue.clear() ;
|
|
}
|
|
|
|
void Trick::Threads::dump( std::ostream & oss ) {
|
|
oss << "Trick::Threads (" << name << ")" << std::endl ;
|
|
oss << " process_type = " ;
|
|
switch ( process_type ) {
|
|
case PROCESS_TYPE_SCHEDULED: oss << "scheduled" << std::endl ; break ;
|
|
case PROCESS_TYPE_ASYNC_CHILD: oss << "asynchronous" << std::endl ; break ;
|
|
case PROCESS_TYPE_AMF_CHILD: oss << "asynchronous must finish with amf_cycle = " << amf_cycle << std::endl ; break ;
|
|
}
|
|
trigger_container.getThreadTrigger()->dump(oss) ;
|
|
oss << " number of scheduled jobs = " << job_queue.size() << std::endl ;
|
|
Trick::ThreadBase::dump(oss) ;
|
|
}
|