org.enodeframework.messaging.impl.RootDispatching.kt Maven / Gradle / Ivy
package org.enodeframework.messaging.impl
import java.util.concurrent.CompletableFuture
import java.util.concurrent.ConcurrentHashMap
class RootDispatching {
val taskCompletionSource: CompletableFuture = CompletableFuture()
private val childDispatchingDict: ConcurrentHashMap = ConcurrentHashMap()
fun addChildDispatching(childDispatching: Any) {
childDispatchingDict[childDispatching] = false
}
fun onChildDispatchingFinished(childDispatching: Any) {
if (childDispatchingDict.remove(childDispatching) != null) {
if (childDispatchingDict.isEmpty()) {
taskCompletionSource.complete(true)
}
}
}
}