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

Threadsafety of Parser::parse() and client side support for response callbacks #5

Open
HuskerC opened this issue Dec 14, 2017 · 3 comments

Comments

@HuskerC
Copy link
Contributor

HuskerC commented Dec 14, 2017

Hello,

great job so far with your jsonrpcpp.
It's easy to use. One thing that came to me while using it was, that trying to use it with a server with
lots of parallel jsonrpc calls, the parser callbacks cannot be used in a multi-threaded environment because they lack synchronisation with the manipulation of the callback container. So if the callback library is changing, while there is heavy load on the line, this could cause some unexpected behaviour. Would be nice, if you might integrate this in a future release.

A second thing that would be nice to have is a callback wrapper for responses on the client side, to support asynchronous call handling.

I wrapped both of those things arround from outside so far.

If you need any assistance I'd be glad to help with a fork.

Best regards and keep going.

@badaix
Copy link
Owner

badaix commented Jan 4, 2018

Hi @HuskerC

sure you can do a fork! As fas as I understand, the problem can be solved by protecting the xxx_callback_ containers with a lock guard.
What is your second thing? Do you want to call the callback functions from a thread? If you have lots of responses, you should limit the number of threads (i.e. not spawn detached threads) and introduce a queue and a thread pool. Maybe that's what you mean with "wrapper", to have this optional outside the lib.

@HuskerC
Copy link
Contributor Author

HuskerC commented Jan 4, 2018

Yeah, the lock guard is what I considererd as well. My second issue is regarding the client side use of your library. You have callbacks in your code, to implement some kind of request queue on server side. Would be nice if the same mechanism would exist for the client side use with a response queue. So that you can place response handlers on the client side to handle async responses for the client’s requests.

Best regards and happy new year.

@ferreteleco
Copy link

ferreteleco commented Apr 24, 2020

Hi!

Regarding this issue, can this library be safely used in a multi-threaded application?

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

3 participants