Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Endpoints returning futures don't work #42

Closed
taion opened this issue Apr 20, 2015 · 3 comments
Closed

Endpoints returning futures don't work #42

taion opened this issue Apr 20, 2015 · 3 comments

Comments

@taion
Copy link
Contributor

taion commented Apr 20, 2015

From #21. Apologies for the formatting.


@taion #21 (comment):

Actually, it turns out that none of the endpoints that expect futures actually work. The issue is that you actually wait on the future here:

https://github.com/tavendo/AutobahnCpp/blob/b44ee2e0582923fe8e175eff1ec726582575f4e2/autobahn/autobahn_impl.hpp#L771

However, this ends up blocking the running thread. If my endpoint does something like

return session.call(procedure, args).then(/* do some work*/);

then the procedure will never actually return, because the running thread is blocked on the done.wait() call, and cannot process the return value from the called procedure and resolve the future.

You can't wait for the future to be resolved there.


@oberstet #21 (comment):

Here is an example for endpoint_fvm_t: https://github.com/tavendo/AutobahnCpp/blob/master/examples/register2.cpp#L63


@taion #21 (comment):

The reason that example works is because the future is ready, so done.wait() returns immediately.

If waiting for the future actually requires handling some input (e.g. you invoke another method and wait for it to finish), then it will not work, because you've blocked the main thread from actually processing the response.


@oberstet #21 (comment):

I see.

I guess it would be good if we first had an example that demonstrates the issue, and then come up with a solution.

This is the harder problem - extending the solution to the variants should then be straightforward.


The issue with variants is no longer there, but endpoints that return futures still don't work. Some combination of boost::asio::io_service::work and std::shared_ptr will probably be required to resolve this.

@davidchappelle
Copy link
Contributor

This is fixed in my fork of autobahn-cpp. Also, the only reason that the examples even work is due to the fact that the boost tcp resolver actually creates a thread that polls the io service.

@taion
Copy link
Contributor Author

taion commented Jul 2, 2015

@davidchappelle Cool - I've actually switched to CppWAMP, but probably having a working "official" AutobahnCpp implementation is a good thing.

@davidchappelle
Copy link
Contributor

This can now be closed.

@taion taion closed this as completed Feb 16, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants