diff --git a/kotlin-native/runtime/src/main/cpp/MainQueueProcessor.cpp b/kotlin-native/runtime/src/main/cpp/MainQueueProcessor.cpp deleted file mode 100644 index b151c17990b..00000000000 --- a/kotlin-native/runtime/src/main/cpp/MainQueueProcessor.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2010-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license - * that can be found in the LICENSE file. - */ - -#include "MainQueueProcessor.hpp" - -#include - -#include "KAssert.h" - -#if KONAN_SUPPORTS_GRAND_CENTRAL_DISPATCH -#include -#endif - -using namespace kotlin; - -namespace { - -#if KONAN_SUPPORTS_GRAND_CENTRAL_DISPATCH -std::atomic isMainQueueProcessed = false; -#endif - -} // namespace - -void kotlin::initializeMainQueueProcessor() noexcept { -#if KONAN_SUPPORTS_GRAND_CENTRAL_DISPATCH - dispatch_async_f( - dispatch_get_main_queue(), nullptr, [](void*) { isMainQueueProcessed.store(true, std::memory_order_relaxed); }); -#endif -} - -bool kotlin::isMainQueueProcessorAvailable() noexcept { -#if KONAN_SUPPORTS_GRAND_CENTRAL_DISPATCH - return isMainQueueProcessed.load(std::memory_order_relaxed); -#else - return false; -#endif -} - -void kotlin::runOnMainQueue(void* arg, void (*f)(void*)) noexcept { - RuntimeAssert(isMainQueueProcessorAvailable(), "Running on main queue when it's not processed"); -#if KONAN_SUPPORTS_GRAND_CENTRAL_DISPATCH - dispatch_async_f(dispatch_get_main_queue(), arg, f); -#endif -} diff --git a/kotlin-native/runtime/src/main/cpp/MainQueueProcessor.hpp b/kotlin-native/runtime/src/main/cpp/MainQueueProcessor.hpp deleted file mode 100644 index 1cdba27778b..00000000000 --- a/kotlin-native/runtime/src/main/cpp/MainQueueProcessor.hpp +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright 2010-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license - * that can be found in the LICENSE file. - */ - -#pragma once - -namespace kotlin { - -void initializeMainQueueProcessor() noexcept; - -bool isMainQueueProcessorAvailable() noexcept; - -// Run `f(arg)` on main queue without waiting for its completion. -// Only valid if `isMainQueueProcessorAvailable()` returns true. -void runOnMainQueue(void* arg, void (*f)(void*)) noexcept; - -} // namespace kotlin diff --git a/kotlin-native/runtime/src/main/cpp/Runtime.cpp b/kotlin-native/runtime/src/main/cpp/Runtime.cpp index 8091674e50e..02089493f5d 100644 --- a/kotlin-native/runtime/src/main/cpp/Runtime.cpp +++ b/kotlin-native/runtime/src/main/cpp/Runtime.cpp @@ -8,7 +8,6 @@ #include "CompilerConstants.hpp" #include "Exceptions.h" #include "KAssert.h" -#include "MainQueueProcessor.hpp" #include "Memory.h" #include "Logging.hpp" #include "ObjCExportInit.h" @@ -171,9 +170,6 @@ bool kotlin::initializeGlobalRuntimeIfNeeded() noexcept { konan::consoleInit(); logging::OnRuntimeInit(); initGlobalMemory(); - if (compiler::objcDisposeOnMain()) { - initializeMainQueueProcessor(); - } #if KONAN_OBJC_INTEROP Kotlin_ObjCExport_initialize(); #endif diff --git a/kotlin-native/runtime/src/mm/cpp/ExtraObjectData.cpp b/kotlin-native/runtime/src/mm/cpp/ExtraObjectData.cpp index d368b82a70f..03f13039dd2 100644 --- a/kotlin-native/runtime/src/mm/cpp/ExtraObjectData.cpp +++ b/kotlin-native/runtime/src/mm/cpp/ExtraObjectData.cpp @@ -5,7 +5,6 @@ #include "ExtraObjectData.hpp" -#include "MainQueueProcessor.hpp" #include "PointerBits.h" #include "ThreadData.hpp" @@ -53,13 +52,7 @@ void mm::ExtraObjectData::UnlinkFromBaseObject() noexcept { void mm::ExtraObjectData::ReleaseAssociatedObject() noexcept { #ifdef KONAN_OBJC_INTEROP if (void* associatedObject = associatedObject_) { - if (getFlag(FLAGS_RELEASE_ON_MAIN_QUEUE) && isMainQueueProcessorAvailable()) { - runOnMainQueue(associatedObject, [](void* obj) { - Kotlin_ObjCExport_releaseAssociatedObject(obj); - }); - } else { - Kotlin_ObjCExport_releaseAssociatedObject(associatedObject); - } + Kotlin_ObjCExport_releaseAssociatedObject(associatedObject); associatedObject_ = nullptr; } #endif