From 90ad34f11469039a064528a2faa5b0456bd2f736 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 29 Dec 2022 08:12:02 +0600 Subject: [PATCH] Update BehaviourContextWithFSM.kt --- .../extensions/behaviour_builder/BehaviourContextWithFSM.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tgbotapi.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSM.kt b/tgbotapi.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSM.kt index cf9850f52b..28463fe89b 100644 --- a/tgbotapi.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSM.kt +++ b/tgbotapi.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSM.kt @@ -173,8 +173,10 @@ class DefaultBehaviourContextWithFSM( fun Job.enableRemoveOnCompletion(state: T) { invokeOnCompletion { launchSafelyWithoutExceptions { - if (this@enableRemoveOnCompletion === statesJobs[state]) { - statesJobs.remove(state) + statesJobsMutex.withLock { + if (this@enableRemoveOnCompletion === statesJobs[state]) { + statesJobs.remove(state) + } } } }