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

com.jd.blockchain.contract.EventResult Maven / Gradle / Ivy

package com.jd.blockchain.contract;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;

import utils.IllegalDataException;

public class EventResult {

    private static final long MAX_SECONDS = 30;

    private CompletableFuture data = new CompletableFuture<>();

    private int opIndex;

    public EventResult() {
    }

    public EventResult(int opIndex) {
        this.opIndex = opIndex;
    }

    public void done(T value) {
        data.complete(value);
    }

    public int opIndex() {
        return this.opIndex;
    }

    public T get() {
        try {
            // 防止长时间阻塞
            return data.get(MAX_SECONDS, TimeUnit.SECONDS);
        } catch (Exception e) {
            throw new IllegalDataException(e.getMessage());
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy