You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We used to use our custom implementation to run some important cleaning procedure on applicationWillTerminate event on iOS. The procedure requires suspend func invocation, so we use custom runblocking that uses NSRunLoop.mainRunLoop inside. I noticed that coroutines in latest versions provides own impl of runBlocking for Native. The test reveals that it doesnt block the thread (MainThread) in applicationWillTerminate.
Sorry, could you explain what you mean? Could you maybe provide a code example? runBlocking is itself not a suspend function, so it certainly blocks the thread it's running on.
Sorry, I still don't understand the expected outcome and how what runBlocking is doing is different. Do you mean that you want the runBlocking code to run on some other dispatcher instead of the current thread? Then, you can do runBlocking(myDispatcher) { myCode() }.
I mean I want and expect that runBlocking in the code above would block the current thread (UI thread in that case), but it doesn't do it. Does it match you expecations or I missed something?
Here's the thing: I can not imagine how this would be possible. Could you please provide some code showing that runBlocking does not block the thread it runs on?
Activity
dkhalanskyjb commentedon Feb 7, 2025
Sorry, could you explain what you mean? Could you maybe provide a code example?
runBlocking
is itself not asuspend
function, so it certainly blocks the thread it's running on.slipdef commentedon Jun 24, 2025
Sorry, didnt notice the notification. I mean that I have iOS code smth like this
Our custom impl of runBlocking for iOS that blocks well (taken from some Kotlin coroutines Github issue):
dkhalanskyjb commentedon Jun 25, 2025
Sorry, I still don't understand the expected outcome and how what
runBlocking
is doing is different. Do you mean that you want therunBlocking
code to run on some other dispatcher instead of the current thread? Then, you can dorunBlocking(myDispatcher) { myCode() }
.slipdef commentedon Jun 30, 2025
@objc private func applicationWillTerminate() { runBlocking { someSuspendFunc() } }
I mean I want and expect that runBlocking in the code above would block the current thread (UI thread in that case), but it doesn't do it. Does it match you expecations or I missed something?
dkhalanskyjb commentedon Jun 30, 2025
Here's the thing: I can not imagine how this would be possible. Could you please provide some code showing that
runBlocking
does not block the thread it runs on?slipdef commentedon Jun 30, 2025
Ok, I will try to come up with repro sample on 1.10.2 version.