[K/N] Remove old release-on-main ^KT-63423
This commit is contained in:
committed by
Space Team
parent
eb0bd0112a
commit
815b452435
@@ -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 <atomic>
|
||||
|
||||
#include "KAssert.h"
|
||||
|
||||
#if KONAN_SUPPORTS_GRAND_CENTRAL_DISPATCH
|
||||
#include <dispatch/dispatch.h>
|
||||
#endif
|
||||
|
||||
using namespace kotlin;
|
||||
|
||||
namespace {
|
||||
|
||||
#if KONAN_SUPPORTS_GRAND_CENTRAL_DISPATCH
|
||||
std::atomic<bool> 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
|
||||
}
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user