package moe.yuuta.workmode.async class StoppableGroup : Stoppable { private val innerList: MutableList = mutableListOf() fun add(stoppable: Stoppable): StoppableGroup { innerList.add(stoppable) return this } fun remove(stoppable: Stoppable): StoppableGroup { innerList.remove(stoppable) return this } override fun stop() { innerList.stream().forEach { it.stop() } } override fun isStopped(): Boolean { for (stoppable in innerList) { if (!stoppable.isStopped()) return false } return true } }