Task::~Task() {
_W("~Task: %s", name_.c_str());
Quit();
- if (use_thread_ && thread_.joinable())
- thread_.join();
+ if (use_thread_ && thread_.joinable()) {
+ if (pthread_self() == thread_.native_handle())
+ thread_.detach();
+ else
+ thread_.join();
+ }
g_main_loop_unref(loop_);
}
// LCOV_EXCL_STOP
void Task::ThreadLoop() {
+ _D("[%s] BEGIN", name_.c_str());
{
std::unique_lock<std::mutex> lock(loop_mutex_);
GSource* source = g_idle_source_new();
g_main_context_dispatch(context_->GetHandle());
g_main_context_pop_thread_default(context_->GetHandle());
+ _D("[%s] END", name_.c_str());
}
void Task::AddEventSource(std::shared_ptr<ISource> source) {