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

Improve locking for real this time #13

Merged
merged 2 commits into from
Nov 10, 2020
Merged

Improve locking for real this time #13

merged 2 commits into from
Nov 10, 2020

Conversation

djc
Copy link
Owner

@djc djc commented Nov 10, 2020

  • Push the lock into the ServiceAccount impls, which means the static data required to get a new token isn't locked
  • Let ServiceAccount::refresh_token() return a clone of the new token so no extra locking is required
  • Now no locks need to be held across await points!
  • Since the locking should be read-heavy, change from a Mutex to an RwLock

@djc
Copy link
Owner Author

djc commented Nov 10, 2020

(And this time I checked that my application still compiles! Should probably add some tests...)

@hrvolapeter
Copy link
Collaborator

Thanks, for the fix. I was also thinking about the tests but I think in this case anything else than integration tests doesn't bring much value but those are also hard to defined and run

@hrvolapeter hrvolapeter merged commit 69e572a into djc:master Nov 10, 2020
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.

2 participants