Comments (10)
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.
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.
The folly library from facebook implements them, but I guess this dependency is way too big.
- https://code.facebook.com/posts/1661982097368498/futures-for-c-11-at-facebook/
- https://github.com/facebook/folly/tree/master/folly/futures
And also this guy that implemented then() in c++14 only : - https://github.com/jaredhoberock/future
from rpclib.
And sorry, it seems I never replied to this: yes, I'd consider it, absolutely.
from rpclib.
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.
What do you think about the proposed overload?
from rpclib.
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.
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.
I think you can take from https://github.com/jaredhoberock/future, it seems promising 👍
from rpclib.
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)
- The info formatted in dispatcher was not shown in client's exception
- Is it possible to use with C??
- Why rpc server throw a exception as "std::system_error" HOT 1
- Is there an upper message size?
- There is a stack overflow problem on the server side of the example
- Does rpclib support enum?
- Access to remote_endpoint information inside bound functor
- C# msgpack RPC server compatible library
- no problem
- the client will not connect to the server if starts before the server HOT 2
- A problem about async_call
- How to use without the server?
- second message has higher latency HOT 1
- sys_close() error crashes server due to uncaught exception
- make sure set flag in gyp file if use c++ exception on msvc
- how to enable logging? HOT 4
- Limitation on the number of fields that can be set in MSGPACK_DEFINE_MAP HOT 2
- Pthread symbols exposed in librpc HOT 2
- [Help] Cannot build custom project with rpclib HOT 2
- Help with Building on Windows
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rpclib.