-
Notifications
You must be signed in to change notification settings - Fork 598
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
Use RwLock for active collectors collection #2851
Conversation
This is a breaking change, please re-target to the next branch. |
I do not know, what this should break, I tested it with current and it worked without any other additions, but I changed it. |
let mutex = Arc::new(tokio::sync::Mutex::new("".to_string()));
Shard::new(mutex, "", shard_info, GatewayIntents::all(), None).await?; This is an example of user code that would break if this PR was merged. Breaking changes means any public API change that stops compilation, with few exceptions. This PR now needs rebasing to drop the extra commits from current and to solve the conflicts. |
Ah, I forgot about the ws_url, I see. I will hust rebase it onto next, this should be enough. |
The Mutex can only be locked once, the RwLock allows multiple readers to get a handle. This is especially needed in functions, which have a high throughput.
cbcaeb8
to
27e26dc
Compare
I now got a lot of "Unresolved reference: |
Disable the tracing_instrument feature in your builds, it is currently broken, that will get those errors to go away. |
I did not get build errors, |
Yes, but you have probably enabled |
I will let rustfmt fix the linter issue. |
Simplify CollectorCallback type Change pointer conversion
Too stupid to see errors sometimes... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, thanks for the PR!
Thanks for the help! |
One of the main functions used a Mutex to guard a shared variable.
This may not impact small bots, but can significantly slow down bots, which have a huge volume of GatewayEvents.
This Pullrequest replaces these Mutexes with a RwLock, which allows multiple simultaneous readers.
This should not break any existing code.