What would be a better way of doing the following:...
# codereview
d
What would be a better way of doing the following:
Copy code
listOf(
  CoroutineScope(<http://Dispatchers.IO|Dispatchers.IO>).launch { ddbTools.deleteTableInRegions(destinationTable, destinationRegions) },
  CoroutineScope(<http://Dispatchers.IO|Dispatchers.IO>).launch { jobService.deleteJobTable() },
  CoroutineScope(<http://Dispatchers.IO|Dispatchers.IO>).launch { jobService.deleteCheckpointTable() }).joinAll()
l
@digitalsanctum
Copy code
withContext(<http://Dispatchers.IO|Dispatchers.IO>) {
    launch { … }
    launch { … }
    launch { … }
} //No need for joinAll() thanks to structured concurrency
👍 2
d
okay, great. thanks!
@louiscad follow-up question: how best to structure things around one launch depending on another?
l
@digitalsanctum Don't launch in that case. Just execute code sequentially.
d
so just let the fact that it will block without launch dictate that it needs to finish before continuing with launches
l
I'm not sure I understand your sentence