Hey all, I'm looking for some help to understand blocking calls within a coroutine.
I was looking at an example for Ktor which uses a coroutine to do a blocking db call. Initially I was wondering why the db call needs to be in another coroutine. Since the route handler function is already in a coroutine, I thought it didn't need to be.
Now I'm thinking it in fact does because there are limited number of potential threads (I know coroutine and threads don't map 1:1) and we don't want to block even this coroutine because it can potentially be reused to process another request. Is my understanding correct?
More generally, is it the case that any time I want to do any time consuming operation, that I should create a new coroutine regardless if I'm already in a coroutine? This is because although there may be other threads available to process information at some point there will be none available and everything will be blocked?