如何处理C++;类和std::javacpp中的未来?

如何处理C++;类和std::javacpp中的未来?,java,c++11,javacpp,Java,C++11,Javacpp,我使用javapp为JNI C++到java < /p> 例如,我使用了一个C++类,它使用了STD:: class cppDemo { public: Demo(); int testInt(int number) { return number; } std::future<int> futureInC() { // future from a promise std::promi

我使用javapp为JNI C++到java < /p>

例如,我使用了一个C++类,它使用了STD::

class cppDemo {
    public:
    Demo();

    int testInt(int number) {
        return number;
    }

    std::future<int> futureInC()
    {
        // future from a promise
        std::promise<int> p;

        std::future<int> f2 = p.get_future();
        std::thread( [](std::promise<int> p){ sleep(2); p.set_value_at_thread_exit(8); },
                     std::move(p) ).detach();

        return f2;
    }
}
类cppDemo{
公众:
演示();
整数测试(整数编号){
返回号码;
}
std::未来公司()
{
//来自承诺的未来
std::promise p;
std::future f2=p.get_future();
std::thread([](std::promise p){sleep(2);p.set_value_在_thread_出口(8);},
std::move(p)).detach();
返回f2;
}
}
我想用CompletableFuture从C函数中得到结果。我有一些方法可以做到这一点,但不起作用

native @StdFuture CompletableFuture<Integer> futureInC(){
    cppDemo.futureInc();
}
native@StdFuture completablefutureinc(){
cppDemo.futureInc();
}

CompletableFutureInc(){
@StdFuture f=@cppDemo.futureInC();
CompletableFuture=新的CompletableFuture();
f、 然后(int value->future.complete(value));
回归未来;
}
如何从Java使用它?谢谢

CompletableFuture<Integer> futureInC(){
    @StdFuture f = @cppDemo.futureInC();
    CompletableFuture<Integer> future = new CompletableFuture<>();
    f.then(int value -> future.complete(value));
    return future;
}