private:
static gboolean IdleCb(gpointer user_data) {
auto* source = static_cast<IdleSource*>(user_data);
+ if (source->IsDisposing()) return G_SOURCE_REMOVE;
auto source_ptr = source->shared_from_this();
if (source->cb_())
return G_SOURCE_CONTINUE;
private:
static gboolean TimeoutCb(gpointer user_data) {
auto* source = static_cast<TimeoutSource*>(user_data);
+ if (source->IsDisposing()) return G_SOURCE_REMOVE;
auto source_ptr = source->shared_from_this();
if (source->cb_())
return G_SOURCE_CONTINUE;
tid_ = getpid();
g_main_loop_run(loop_);
- while (g_main_context_pending(context_->GetHandle()))
- g_main_context_dispatch(context_->GetHandle());
-
tid_ = -1;
g_main_loop_unref(loop_);
loop_ = nullptr;
pthread_setname_np(pthread_self(), name_.c_str());
g_main_loop_run(loop_);
- while (g_main_context_pending(context_->GetHandle()))
- g_main_context_dispatch(context_->GetHandle());
g_main_context_pop_thread_default(context_->GetHandle());
{
ASSERT_EQ(touched_, true);
}
+TEST_F(TizenCoreTest, tizen_core_add_idle_job_P2) {
+ tizen_core_h core = nullptr;
+ tizen_core_task_get_tizen_core(main_task_, &core);
+ ASSERT_NE(core, nullptr);
+
+ tizen_core_source_h source = nullptr;
+ int ret = tizen_core_add_idle_job(
+ core,
+ [](void* user_data) {
+ return true;
+ },
+ this, &source);
+
+ ret = tizen_core_add_idle_job(
+ core,
+ [](void* user_data) {
+ auto* test = static_cast<TizenCoreTest*>(user_data);
+ test->touched_ = true;
+ tizen_core_task_quit(test->main_task_);
+ return false;
+ },
+ this, &source);
+ ASSERT_EQ(ret, TIZEN_CORE_ERROR_NONE);
+ ASSERT_NE(source, nullptr);
+
+ tizen_core_task_run(main_task_);
+ ASSERT_EQ(touched_, true);
+}
+
TEST_F(TizenCoreTest, tizen_core_add_idle_job_N) {
int ret = tizen_core_add_idle_job(nullptr, nullptr, nullptr, nullptr);
ASSERT_EQ(ret, TIZEN_CORE_ERROR_INVALID_PARAMETER);