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

ru.tinkoff.kora.common.util.flow.FromCallablePublisher Maven / Gradle / Ivy

There is a newer version: 1.1.16
Show newest version
package ru.tinkoff.kora.common.util.flow;

import ru.tinkoff.kora.common.Context;

import java.util.concurrent.Callable;
import java.util.concurrent.Flow;

public class FromCallablePublisher implements Flow.Publisher {
    private final Context context;
    private final Callable value;

    public FromCallablePublisher(Context context, Callable value) {
        this.context = context;
        this.value = value;
    }

    @Override
    public void subscribe(Flow.Subscriber subscriber) {
        var s = new LazySingleSubscription<>(subscriber, context, value);
        subscriber.onSubscribe(s);
    }

    public final Callable callable() {
        return this.value;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy