RecoSim  1.0
 All Classes Files Functions Variables Enumerations
reconf_threads.h
Go to the documentation of this file.
1 
21 #ifndef RECONF_THREADS_H
22 #define RECONF_THREADS_H
23 
26 #include "utils.h"
27 
28 template<int Ni, int No> void reconf_thread_standard(Reconf_thread_interface &reconf_interface, User_algorithm_interface<Ni, No> &user_algo_interface) {
29 
30  sc_process_handle p_handle;
31 
32  while(true) {
33  wait(reconf_interface.configuration_updated());
34 
35  if(p_handle.valid()) {
36  // Kill thread
37 #ifdef GENERATE_LOG_FILE
38  Simulation_controller::get_logfile() << reconf_interface.get_name() << ": Waiting for the end of previous user algorithm..." << endl;
39 #endif
40  if(!p_handle.terminated()) wait(p_handle.terminated_event());
41 #ifdef GENERATE_LOG_FILE
42  Simulation_controller::get_logfile() << reconf_interface.get_name() << ": Previous user algorithm terminated successfully!" << endl;
43 #endif
44  }
45 
46  void *user_interface_ptr = &user_algo_interface;
47 
48 #ifdef GENERATE_LOG_FILE
49  Simulation_controller::get_logfile() << reconf_interface.get_name() << ": Configuration update: Algorithm " << reconf_interface.get_current_implementation_id()
50  << " (" << reconf_interface.get_implementation_vector().at(reconf_interface.get_current_implementation_id()).get_name() << ")" << endl;
51 #endif
52  p_handle = sc_spawn(sc_bind(reconf_interface.get_implementation_vector().at(reconf_interface.get_current_implementation_id()).get_algorithm_thread_ptr(), user_interface_ptr));
53 
54  reconf_interface.finish_configuration();
55  }
56 }
57 
58 #endif
Definition: reconf_thread_interface.h:28
Definition: user_algorithm_interface.h:35