- Timestamp:
- Mar 20, 2014, 2:35:01 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/Pacpus/kernel/ComponentBase.h
r272 r281 38 38 class QWidget; 39 39 40 namespace boost { 41 namespace program_options { 40 namespace boost 41 { 42 class exception_ptr; 43 44 namespace program_options 45 { 42 46 class options_description_easy_init; 43 } 44 } 47 } // namespace program_options 48 49 } // namespace boost 45 50 46 51 namespace pacpus { … … 200 205 /// called by the ComponentManager to start the component 201 206 int startComponent(); 207 void startComponentInThread(); 208 void startComponentWithException(boost::exception_ptr& error); 202 209 203 210 /// called by the ComponentManager to stop the component -
trunk/src/PacpusLib/ComponentBase.cpp
r280 r281 11 11 #include <Pacpus/kernel/PacpusException.h> 12 12 13 #include <boost/bind/bind.hpp> 14 #include <boost/exception/detail/exception_ptr.hpp> 15 #include <boost/exception/diagnostic_information.hpp> 16 #include <boost/exception/exception.hpp> 13 17 #include <boost/program_options/parsers.hpp> 14 18 #include <boost/program_options/variables_map.hpp> … … 127 131 } 128 132 133 void ComponentBase::startComponentWithException(boost::exception_ptr& error) 134 { 135 try { 136 startActivity(); 137 error = boost::exception_ptr(); 138 } catch (...) { 139 error = boost::current_exception(); 140 } 141 } 142 143 void ComponentBase::startComponentInThread() 144 { 145 boost::exception_ptr error; 146 boost::thread t( 147 boost::bind( 148 &ComponentBase::startComponentWithException, 149 this, 150 boost::ref(error) 151 ) 152 ); 153 t.join(); 154 if (error) { 155 try { 156 boost::rethrow_exception(error); 157 } catch (boost::exception& e) { 158 LOG_FATAL("[" << getName() << "]" << "\tboost::exception thrown: " << boost::diagnostic_information(e)); 159 //throw; 160 } 161 } 162 } 163 129 164 int ComponentBase::startComponent() 130 165 { … … 135 170 136 171 setActive(true); 137 boost::thread worker(&ComponentBase::startActivity, this); 172 boost::thread worker(&ComponentBase::startComponentInThread, this); 173 //boost::thread worker(&ComponentBase::startActivity, this); 138 174 //startActivity(); 139 175 return true;
Note:
See TracChangeset
for help on using the changeset viewer.