jkbbwr
01/07/2019, 7:57 PMval threadPool = newSingleThreadContext("git-clone-subprocess-pool")
suspend fun clone(urL: String) {
val result = withContext(threadPool) {
async {
val pb = NuProcessBuilder(listOf("/bin/cat"))
val process = pb.start()
process.waitFor(0, TimeUnit.SECONDS)
}
}
val exitcode = result.await()
}
Allan Wang
01/07/2019, 7:58 PMasync
and await
then it's good. Otherwise just use withContext
Allan Wang
01/07/2019, 7:59 PMasync
, though as you can see in the post above there are sometimes issuesjkbbwr
01/07/2019, 7:59 PMsuspend fun clone(urL: String) {
val exitcode = withContext(threadPool) {
val pb = NuProcessBuilder(listOf("/bin/cat"))
val process = pb.start()
process.waitFor(0, TimeUnit.SECONDS)
}
}
jkbbwr
01/07/2019, 7:59 PMAllan Wang
01/07/2019, 8:00 PMclone(url: String) = withContext(threadPool) ...
louiscad
01/07/2019, 10:23 PM<http://Dispatchers.IO|Dispatchers.IO>
for this kind of usage