MCPcopy Create free account
hub / github.com/OpenHD/OpenHD / execute_async

Method execute_async

OpenHD/ohd_common/src/openhd_util_async.cpp:55–76  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53}
54
55void openhd::AsyncHandle::execute_async(const std::string tag,
56 std::function<void()> runnable) {
57 auto task = std::make_shared<openhd::AsyncHandle::RunningTask>();
58 task->tag = tag;
59 task->runnable = std::move(runnable);
60 task->done = false;
61 task->worker_thread = std::make_shared<std::thread>([task]() {
62 auto console = openhd::log::get_default();
63 console->debug("{} begin", task->tag);
64 try {
65 task->runnable();
66 } catch (std::exception& ex) {
67 console->warn("Exception on {},{}", task->tag, ex.what());
68 } catch (...) {
69 console->warn("Unknown Exception on {}", task->tag);
70 }
71 console->debug("{} done", task->tag);
72 task->done = true;
73 });
74 std::lock_guard<std::mutex> lock(m_threads_mutex);
75 m_tasks.push_back(task);
76}
77
78void openhd::AsyncHandle::execute_command_async(std::string tag,
79 std::string command) {

Callers 4

mainFunction · 0.80
start_asyncMethod · 0.80
stop_asyncMethod · 0.80

Calls 2

debugMethod · 0.80
push_backMethod · 0.80

Tested by 1

mainFunction · 0.64