Code Monkey home page Code Monkey logo

Comments (10)

ahoarau avatar ahoarau commented on July 22, 2024 1

Excellent. I really look forward for this feature.

For now I'm using this hack in Qt :

    connect(ui->actionCalibrate,&QAction::triggered,this,[=](){

        auto f = client->async_call("calibrate");

        QFuture<void> future = QtConcurrent::run([this,&f](){
            bool done = f.get().as<bool>();
        });
    
    });

from rpclib.

ahoarau avatar ahoarau commented on July 22, 2024

Would you consider having rpclib::future instead of std::future ? I read that .then() operator is not gonna be in c++ for a while.

from rpclib.

ahoarau avatar ahoarau commented on July 22, 2024

The folly library from facebook implements them, but I guess this dependency is way too big.

from rpclib.

sztomi avatar sztomi commented on July 22, 2024

And sorry, it seems I never replied to this: yes, I'd consider it, absolutely.

from rpclib.

sztomi avatar sztomi commented on July 22, 2024

So my thinking is: providing rpc::future is one way to solve this, but it would also be possible to do it without that. For example, async_call could have an overloaded signature like:

std::future<RPCLIB_MSGPACK::object_handl> async_call(invocation i, callback c);

And used like:

client.async_call({"hello, 2, 3}, [](something) { ... });

Obviously, rpc::future would look smoother but that's paid for by additional complexity in the library. That is not say I'm against it, but I do want to see what options are there.

BTW I'm doing some breaking changes for 3.0, so pretty much anything goes for now in terms of interface breakage.

from rpclib.

sztomi avatar sztomi commented on July 22, 2024

What do you think about the proposed overload?

from rpclib.

ahoarau avatar ahoarau commented on July 22, 2024

That would work, but I think that would be clearer to have :

auto f = client->async_call("add",2,3);
auto f = client->async_call("add",2,3).then( [](){} );

Rather than :

auto f = client->async_call("add",2,3);
auto f = client->async_call( {"add",2,3} , [](){} ); // is that you'd construct the invoker ?

from rpclib.

sztomi avatar sztomi commented on July 22, 2024

Yeah, that's pretty much my proposal.

I agree that .then is probably better, but it's also a bit more complicated to implement. I wonder if there is a good C++11 implementation of it which is a lot like std::future but with then

from rpclib.

ahoarau avatar ahoarau commented on July 22, 2024

I think you can take from https://github.com/jaredhoberock/future, it seems promising 👍

from rpclib.

sztomi avatar sztomi commented on July 22, 2024

If I understand correctly, that is a third option: then as a free function.

But I also found that boost::future can provide a then function. So I'll probably use that.

from rpclib.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.