Skip to content

Make ads::client::Client sync #39

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

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

cartercanedy
Copy link

@cartercanedy cartercanedy commented May 7, 2025

This is the minimum diff required to make ads::client::Client sync. I considered making a special Error variant specific to locks, but I'm pretty sure that there's no way application code to induce a poisoned lock, and any poisons that come from standard library panics should definitely result in an aborted application.

Feel free to modify.

@birkenfeld
Copy link
Owner

Hi, thanks for the PR!

The problem is that when communicate can be called concurrently, replies are not guaranteed to end up where they need to go - if two threads start a request at the same time, the reader thread will just send both replies to the channel, and each calling thread will get one, but they might be the wrong ones.

It's certainly possible to make it work, but so far I haven't thought about what the minimal/best change to the architecture would look like to achieve that.

@cartercanedy
Copy link
Author

I wrapped all of the client network IO in a mutexed block. I can see this getting more efficient if you wanted to adopt a coroutine-oriented api with primitives from async_lock

@cartercanedy
Copy link
Author

@birkenfeld I ended up refactoring the background worker logic a bit so that the client can dispatch requests concurrently and receive their responses asynchronously

@cartercanedy cartercanedy force-pushed the master branch 2 times, most recently from 2608f1a to 060d3c2 Compare May 9, 2025 19:16
@cartercanedy
Copy link
Author

Hey @birkenfeld just a friendly ping :)

@birkenfeld
Copy link
Owner

Thanks! This isn't forgotten, I just need a quiet time for review... Fortunately some leave is coming up during which I might have time for that.

@cartercanedy
Copy link
Author

No problem, like I said before, feel free to suggest/make changes!

@cartercanedy
Copy link
Author

I also had a productive conversation with bhf support about routing in general, and now I'm fairly certain that the Source::Auto variant is pretty much never valid unless you manually configure the routes on the remote (which contradicts the semantics of "auto" routing, imo). I'll create another issue with better details

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

Successfully merging this pull request may close these issues.

Making ads::client::Client implement the Send and Sync traits by not using RefCell and Cell in it
2 participants