From 834999a7661e0c9cd381468778a9e86eb425ee80 Mon Sep 17 00:00:00 2001 From: "Ilya.Usov" Date: Mon, 4 Sep 2023 13:57:39 +0200 Subject: [PATCH] Allow creation on background by default on kotlin side --- .../jetbrains/rd/framework/base/RdExtBase.kt | 27 +++++-------------- .../nova/kotlin/Kotlin11Generator.kt | 1 + 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/rd-kt/rd-framework/src/main/kotlin/com/jetbrains/rd/framework/base/RdExtBase.kt b/rd-kt/rd-framework/src/main/kotlin/com/jetbrains/rd/framework/base/RdExtBase.kt index c501f5c17..cd2c9b4db 100644 --- a/rd-kt/rd-framework/src/main/kotlin/com/jetbrains/rd/framework/base/RdExtBase.kt +++ b/rd-kt/rd-framework/src/main/kotlin/com/jetbrains/rd/framework/base/RdExtBase.kt @@ -73,7 +73,7 @@ abstract class RdExtBase : RdReactiveBase() { val scheduler = when (extThreading) { ExtThreadingKind.Default -> parentProtocol.scheduler ExtThreadingKind.CustomScheduler -> CustomExtScheduler() - ExtThreadingKind.AllowBackgroundCreation -> ExtSchedulerWrapper(parentProtocol.scheduler) + ExtThreadingKind.AllowBackgroundCreation -> parentProtocol.scheduler } val signal = createExtSignal() @@ -86,8 +86,10 @@ abstract class RdExtBase : RdReactiveBase() { if (scheduler is ExtSchedulerBase && extThreading != ExtThreadingKind.Default) scheduler.setActiveCurrentThread(activeLifetime) - super.preInit(lifetime, proto) - super.init(lifetime, proto, ctx) + AllowBindingCookie.allowBind { + super.preInit(lifetime, proto) + super.init(lifetime, proto, ctx) + } val info = ExtCreationInfo(location, (parent as? RdBindableBase)?.containingExt?.rdid, serializationHash, this) @@ -172,6 +174,8 @@ abstract class RdExtBase : RdReactiveBase() { enum class ExtThreadingKind { Default, CustomScheduler, + + @Deprecated("Creating on the background is allowed by default") AllowBackgroundCreation } } @@ -198,23 +202,6 @@ internal abstract class ExtSchedulerBase : IScheduler { } } -internal class ExtSchedulerWrapper(val realScheduler: IScheduler) : ExtSchedulerBase() { - - override fun queue(action: () -> Unit) { - realScheduler.queue(action) - } - - override val isActive: Boolean - get() = realScheduler.isActive || isActiveThread() - - override val executionOrder: ExecutionOrder - get() = realScheduler.executionOrder - - override fun flush() { - throw InvalidOpenTypeException("Unsupported") - } -} - internal class CustomExtScheduler : ExtSchedulerBase() { private val locker = Any() diff --git a/rd-kt/rd-gen/src/main/kotlin/com/jetbrains/rd/generator/nova/kotlin/Kotlin11Generator.kt b/rd-kt/rd-gen/src/main/kotlin/com/jetbrains/rd/generator/nova/kotlin/Kotlin11Generator.kt index 89c154391..f09a4d2d2 100644 --- a/rd-kt/rd-gen/src/main/kotlin/com/jetbrains/rd/generator/nova/kotlin/Kotlin11Generator.kt +++ b/rd-kt/rd-gen/src/main/kotlin/com/jetbrains/rd/generator/nova/kotlin/Kotlin11Generator.kt @@ -47,6 +47,7 @@ open class Kotlin11Generator( enum class ExtThreadingKind { Default, CustomScheduler, + @Deprecated("Creating on the background is allowed by default") AllowBackgroundCreation }