tizen_core_add_idle_job(
core_, [](void* user_data) -> bool {
auto* service = static_cast<Service*>(user_data);
+ service->tid_ = gettid();
service->OnCreate();
service->state_ = Service::State::Running;
ServiceManager::GetInst().NotifyServiceStateChanged(service);
core_,
[](void* user_data) -> bool {
auto* service = static_cast<Service*>(user_data);
+ std::unique_lock<std::mutex> idle_lock(service->mutex_);
service->OnDestroy();
service->cond_var_.notify_one();
return false;
this, &source);
tizen_core_task_quit(task_);
- cond_var_.wait(lock, [this]() { return state_ == State::Destroyed; });
+ if (gettid() != tid_)
+ cond_var_.wait(lock, [this]() { return state_ == State::Destroyed; });
+
running_ = false;
}