Animesh Sahu
12/02/2019, 4:10 PMsuspendedTransactionAsync()
and newSuspendedTransaction()
i know one of them return Deferred and other the direct value. But i see that both of them suspend at the time of call, i.e. if `suspendedTransactionAsync()`suspends at the time of call then what is use of await()
on the deferred? Like CoroutineScope.async()
doesn't suspend at the time of call but rather when await()
is called on that right, so what's difference b/w them(transactions)?tapac
12/02/2019, 5:15 PMAnimesh Sahu
12/02/2019, 5:19 PMtapac
12/02/2019, 5:20 PMAnimesh Sahu
12/02/2019, 5:30 PMtapac
12/02/2019, 5:31 PMBecause Exposed uses JDBC-api to interact with databases that was designed in an era of blocking apis.
Please note what such code remains blocking (as it still uses JDBC) and you should not try to share a transaction between multiple threads as it will lead to undefined behaviour.
Animesh Sahu
12/02/2019, 5:32 PMval job = async(<http://Dispatchers.IO|Dispatchers.IO>) { // it does not suspend here at this line
// suspendable tasks
}
hob.await() //it does suspend here and should
tapac
12/02/2019, 5:33 PMsuspendedTransactionAsync
Animesh Sahu
12/02/2019, 5:35 PM