Marionette: Post initializeHarikoff() as a lambda
This commit is contained in:
@@ -40,7 +40,6 @@ void ComponentThread::signalThread(std::thread::id id)
|
|||||||
|
|
||||||
void ComponentThread::main(ComponentThread& self)
|
void ComponentThread::main(ComponentThread& self)
|
||||||
{
|
{
|
||||||
std::cout << __func__ << ": Entered." << std::endl;
|
|
||||||
// We sleep on spawn until the main thread tells us to continue.
|
// We sleep on spawn until the main thread tells us to continue.
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lock(self.startupSync.mutex);
|
std::unique_lock<std::mutex> lock(self.startupSync.mutex);
|
||||||
|
|||||||
@@ -21,25 +21,25 @@ int main(int argc, char **argv, char **envp)
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
std::cout << __func__ << ": Entering main()" << std::endl;
|
std::cout << __func__ << ": Entering main()" << std::endl;
|
||||||
|
boost::asio::io_service mrntLoop;
|
||||||
|
boost::asio::io_service::work work(mrntLoop);
|
||||||
|
|
||||||
// Validate thread IDs
|
// Validate thread IDs
|
||||||
hk::ComponentThread::validateThreadIds();
|
hk::ComponentThread::validateThreadIds();
|
||||||
|
|
||||||
int ret = hk::initializeHarikoff(argc, argv, envp);
|
// Post initializeHarikoff to mrntLoop
|
||||||
if (ret != 0) {
|
mrntLoop.post([&]()
|
||||||
return ret;
|
{
|
||||||
}
|
int ret = hk::initializeHarikoff(argc, argv, envp);
|
||||||
|
if (ret != 0)
|
||||||
|
{
|
||||||
|
std::cerr << "Initialization failed with code: "
|
||||||
|
<< ret << std::endl;
|
||||||
|
std::exit(ret);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Signal all threads
|
mrntLoop.run();
|
||||||
for (const auto& [id, componentThread]
|
|
||||||
: hk::ComponentThread::componentThreads) {
|
|
||||||
hk::ComponentThread::signalThread(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Infinite loop calling yield
|
|
||||||
while (true) {
|
|
||||||
std::this_thread::yield();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (const std::exception& e)
|
catch (const std::exception& e)
|
||||||
{
|
{
|
||||||
@@ -47,7 +47,8 @@ int main(int argc, char **argv, char **envp)
|
|||||||
<< std::endl;
|
<< std::endl;
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
catch (...) {
|
catch (...)
|
||||||
|
{
|
||||||
std::cerr << __func__ << ": Unknown exception occurred" << std::endl;
|
std::cerr << __func__ << ": Unknown exception occurred" << std::endl;
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
@@ -70,6 +71,7 @@ static int initializeHarikoff(int argc, char **argv, char **envp)
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
options.parseArguments(argc, argv, envp);
|
options.parseArguments(argc, argv, envp);
|
||||||
|
std::cout << options.stringifyOptions() << std::endl;
|
||||||
}
|
}
|
||||||
catch (const std::invalid_argument& e)
|
catch (const std::invalid_argument& e)
|
||||||
{
|
{
|
||||||
@@ -78,18 +80,22 @@ static int initializeHarikoff(int argc, char **argv, char **envp)
|
|||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.printUsage) {
|
if (options.printUsage)
|
||||||
|
{
|
||||||
std::cout << options.getUsage() << std::endl;
|
std::cout << options.getUsage() << std::endl;
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << options.stringifyOptions() << std::endl;
|
|
||||||
DeviceManager::getInstance().collateAllDeviceSpecs();
|
DeviceManager::getInstance().collateAllDeviceSpecs();
|
||||||
DeviceManager::getInstance().parseAllDeviceSpecs();
|
DeviceManager::getInstance().parseAllDeviceSpecs();
|
||||||
std::cout << DeviceManager::stringifyDeviceSpecs() << std::endl;
|
std::cout << DeviceManager::stringifyDeviceSpecs() << std::endl;
|
||||||
sense_api::SenseApiManager::getInstance().loadAllSenseApiLibsFromOptions();
|
sense_api::SenseApiManager::getInstance().loadAllSenseApiLibsFromOptions();
|
||||||
|
|
||||||
/* Start the threads */
|
/* Start the threads */
|
||||||
|
for (const auto& [id, componentThread]
|
||||||
|
: hk::ComponentThread::componentThreads) {
|
||||||
|
hk::ComponentThread::signalThread(id);
|
||||||
|
}
|
||||||
|
|
||||||
std::cout << __func__ << ": Exiting" << std::endl;
|
std::cout << __func__ << ": Exiting" << std::endl;
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user