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

com.youthlin.rpc.core.RpcFuture Maven / Gradle / Ivy

There is a newer version: 1.1.1
Show newest version
package com.youthlin.rpc.core;

import java.util.concurrent.Future;

/**
 * 如果是异步调用, 每个线程对应的 Future.
 * 每次调用会对应一个 Future, 因此应该在调用后立即 {@link #get()}
 *
 * @see FutureAdapter
 * 创建: youthlin.chen
 * 时间: 2017-11-27 14:41
 */
public class RpcFuture {
    private static ThreadLocal LOCAL = new ThreadLocal() {
        @Override
        protected RpcFuture initialValue() {
            return new RpcFuture();
        }
    };
    private Future future;

    private RpcFuture() {
    }

    @SuppressWarnings("unchecked")
    static  RpcFuture getRpcFuture() {
        return LOCAL.get();
    }

    void setFuture(Future future) {
        this.future = future;
    }

    @SuppressWarnings("unchecked")
    public static  Future get() {
        return LOCAL.get().future;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy