Hi, I'm trying to get a better understanding of th...
# exposed
m
Hi, I'm trying to get a better understanding of the difference between
suspendedTransactionAsync
and
suspendedTransaction
. As I understand
suspendedTransaction
simply runs the blocking code on a separate thread whereas the former is actually non-blocking and we will await for the operation to complete. If exposed uses JDBC API under the hood, I don't quite understands how this works in practice.
m
I think
suspendedTransactionAsync
is a design fluke and you should not use it. If a library function is asynchronous it should be suspending, not return a deferred. that is, suspended transaction is all you need.
Copy code
suspendedTransaction { ... }
if you want true parallel logic you should tailor it to your actual needs, don't use
suspendedTransactionAsync
Copy code
coroutineScope {
  async { suspendedTransaction { ... } }
  async { suspendedTransaction { ... } }
}