Morning! I would like to know how I could, when sp...
# coroutines
s
Morning! I would like to know how I could, when spring boot is shutting down, await for a CoroutineScope childrens to end, more especifically I would like to "close" a CoroutineScope without cancelling its childrens, that is, prevent new jobs from being posted and throw if an attempt is make, and then await for its childrens to finish their work, and only then finish the application. This is not specific for Spring Boot, I only need to figure out how to close a Coroutine Scope without cancelling its children, how could I do this?
s
I don’t think cancelling a coroutine scope is the best solution here. I would create a channel that is used to submit new tasks, and then close the channel when you don’t want any new tasks to be submitted. You can launch a job to read the tasks from the channel and execute them (in parallel, if you want). To wait for all the tasks to complete, just
join()
that job.
s
I think you are looking for this https://github.com/arrow-kt/suspendapp