in sdk/src/utils/ThreadExecutor.cc [47:71]
void ThreadExecutor::execute(Runnable* task)
{
auto main = [task, this] {
PDS_LOG(LogLevel::LogDebug, TAG, "task(%p) enter execute main thread", task);
task->run();
delete task;
detach(std::this_thread::get_id());
PDS_LOG(LogLevel::LogDebug, TAG, "task(%p) leave execute main thread", task);
};
State expected;
do
{
expected = State::Free;
if (state_.compare_exchange_strong(expected, State::Locked))
{
std::thread t(main);
const auto id = t.get_id();
threads_.emplace(id, std::move(t));
state_ = State::Free;
return;
}
} while (expected != State::Shutdown);
return;
}