Changeset 281 in pacpusframework for trunk/src/PacpusLib/ComponentBase.cpp
- Timestamp:
- Mar 20, 2014, 2:35:01 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.