<@U5LAZSK9A> It would be great is somebody ports a...
# coroutines
@geekasm It would be great is somebody ports async sql driver for Postresql to Kotlin. Meanwhile, you need to follow these steps: 1. Decide how many concurrent SQL operations you’d like to have at max (let’s call it
). 2. Define your own context for SQL operations like this:
val SQL = newFixedThreadPoolContext(n, "SQL")
3. Wrap your SQL operations into
run(SQL) { ... }
invocation. It works best if you ecapsulate them in suspending functions like this:
Copy code
suspend fun mySqlOperation(params) = run(SQL) { .... }
Now you can use those suspending functions from coroutines and it will not block anything.
K 1
👍 2