-
Notifications
You must be signed in to change notification settings - Fork 27
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
Asyncronous Server #7
Open
semmel
wants to merge
20
commits into
uskr:master
Choose a base branch
from
semmel:async-server
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Update pulling in changes from the original repo
wip (async server): began introducing futures
…::Value compatible type futures.
…hod dispatched to is not asynchronous. i.e does not return a future
…synchronous handler
Thia is indeed a nice addition. I will dive in all the changes you posted to see what I can merge, without breaking the basic requirements of this project. Thank you! |
…ric error code if std::system_error is thrown
…d params' error for method invocation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We use jsonrpc-lean to expose a C++ VoIP and SIP client via a Unix domain socket to a Node.js client on the same machine. The number of methods which need to be wired through JSON-RPC Api and the total count of calls can be reduced if longer running methods (like playing a WAV file over VoIP) are permitted to run as background threads thus not blocking the JSON-RPC server for parallel commands and without polling responding to the JSON-RPC request after the time the operation completed.
In single-threaded JavaScript one uses callbacks which are nicely wrapped by Promises. C++ Futures with TS for Concurrency for C++14 together with C++ Promises wrap C++ threads very similar to JS Promises. Both make creating and consuming background computations easy. Unfortunately the JSPromise-like C++
Future::then
callback interface is still on the roadmap for the C++ standard. Thus the introduced dependency on the "polyfill" inboost::thread
makes the setup of jsonrpc-lean more complicated. I.e.boost::thread
needs to be available as a library.The implementation of asynchronous server request offered here is far from perfect. Mostly because I couldn't figure out easy how the intricate template machinery for storing the strongly typed methods in their return values and parameters by the
Dispatcher
works.However, I attempted to minimise the changes to the public and internal jsonrpc-lean API. Except for the problem of future-returning Lambdas (see the section in the Readme) I just added the single new method
Dispatcher::asyncHandleRequest
.