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

com.englishtown.vertx.cassandra.FutureUtils Maven / Gradle / Ivy

There is a newer version: 3.6.1
Show newest version
package com.englishtown.vertx.cassandra;

import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import io.vertx.core.Context;
import io.vertx.core.Vertx;

/**
 * Future vert.x utils
 */
public class FutureUtils {

    private FutureUtils() {
    }

    /**
     * Add a future callback to run on the vert.x context
     *
     * @param future listenable future to have the callback added to
     * @param callback the callback for the listenable future
     * @param vertx
     * @param 
     */
    public static  void addCallback(final ListenableFuture future, FutureCallback callback, Vertx vertx) {
        final Context context = vertx.getOrCreateContext();
        Futures.addCallback(future, callback, command -> context.runOnContext(aVoid -> command.run()));
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy