From b07d17b980027f66676493cbb275c610ff7ca013 Mon Sep 17 00:00:00 2001 From: Christian Melchior Date: Wed, 6 Sep 2023 14:20:21 +0200 Subject: [PATCH] Fix default schedulers on Linux and Windows --- .../kotlin/io/realm/kotlin/internal/interop/RealmInterop.kt | 2 +- packages/jni-swig-stub/src/main/jni/realm_api_helpers.cpp | 5 +++++ packages/jni-swig-stub/src/main/jni/realm_api_helpers.h | 3 +++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/RealmInterop.kt b/packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/RealmInterop.kt index b5965d8106..c2b2a07d8f 100644 --- a/packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/RealmInterop.kt +++ b/packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/RealmInterop.kt @@ -182,7 +182,7 @@ actual object RealmInterop { } actual fun realm_create_scheduler(): RealmSchedulerPointer = - LongPointerWrapper(realmc.realm_scheduler_make_default()) + LongPointerWrapper(realmc.realm_create_generic_scheduler()) actual fun realm_create_scheduler(dispatcher: CoroutineDispatcher): RealmSchedulerPointer = LongPointerWrapper(realmc.realm_create_scheduler(JVMScheduler(dispatcher))) diff --git a/packages/jni-swig-stub/src/main/jni/realm_api_helpers.cpp b/packages/jni-swig-stub/src/main/jni/realm_api_helpers.cpp index e22bec122e..223ed7bd79 100644 --- a/packages/jni-swig-stub/src/main/jni/realm_api_helpers.cpp +++ b/packages/jni-swig-stub/src/main/jni/realm_api_helpers.cpp @@ -1048,3 +1048,8 @@ realm_sync_thread_error(realm_userdata_t userdata, const char* error) { env->CallVoidMethod(static_cast(userdata), java_callback_method, to_jstring(env, msg)); jni_check_exception(env); } + +realm_scheduler_t* +realm_create_generic_scheduler() { + return new realm_scheduler_t{realm::util::Scheduler::make_generic()}; +} diff --git a/packages/jni-swig-stub/src/main/jni/realm_api_helpers.h b/packages/jni-swig-stub/src/main/jni/realm_api_helpers.h index cc845116ed..210202a6c9 100644 --- a/packages/jni-swig-stub/src/main/jni/realm_api_helpers.h +++ b/packages/jni-swig-stub/src/main/jni/realm_api_helpers.h @@ -134,4 +134,7 @@ realm_sync_thread_destroyed(realm_userdata_t userdata); void realm_sync_thread_error(realm_userdata_t userdata, const char* error); +realm_scheduler_t* +realm_create_generic_scheduler(); + #endif //TEST_REALM_API_HELPERS_H