All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.enodeframework.messaging.impl.RootDispatching Maven / Gradle / Ivy

There is a newer version: 1.1.10
Show newest version
package org.enodeframework.messaging.impl;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentHashMap;

public class RootDispatching {
    private final CompletableFuture taskCompletionSource;
    private final ConcurrentHashMap childDispatchingDict;

    public RootDispatching() {
        taskCompletionSource = new CompletableFuture<>();
        childDispatchingDict = new ConcurrentHashMap<>();
    }

    public CompletableFuture getTaskCompletionSource() {
        return taskCompletionSource;
    }

    public void addChildDispatching(Object childDispatching) {
        childDispatchingDict.put(childDispatching, false);
    }

    public void onChildDispatchingFinished(Object childDispatching) {
        if (childDispatchingDict.remove(childDispatching) != null) {
            if (childDispatchingDict.isEmpty()) {
                taskCompletionSource.complete(true);
            }
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy