running_ = true;
}
+void Service::QuitSelf() {
+ auto self = shared_from_this();
+ tizen_core_task_quit(task_);
+ OnBaseDestroy();
+}
+
void Service::Quit() {
if (!IsRunning()) return;
+ running_ = false;
+ if (tid_ == gettid()) {
+ QuitSelf();
+ return;
+ }
+
tizen_core_source_h source = nullptr;
tizen_core_add_idle_job(
core_,
[](void* user_data) -> bool {
auto* service = static_cast<Service*>(user_data);
- auto service_ptr = service->shared_from_this();
- service->OnBaseDestroy();
+ service->QuitSelf();
return false;
},
this, &source);
-
- tizen_core_task_quit(task_);
- running_ = false;
+ if (source == nullptr) _E("Failed to add idle job");
}
void Service::SendMessage(const tizen_base::Bundle& envelope) {
void OnBaseMessageReceived(const std::string& sender,
const tizen_base::Bundle& envelope);
void NotifyStateChanged();
+ void QuitSelf();
bool Init();
void Shutdown();