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

WIP FallbackRwLock #2893

Closed

Conversation

tkporter
Copy link
Collaborator

@tkporter tkporter commented Nov 7, 2023

Description

Drive-by changes

Related issues

Backward compatibility

Testing

@tkporter tkporter requested a review from daniel-savu as a code owner November 7, 2023 11:11
Copy link
Contributor

@daniel-savu daniel-savu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

self.0
.try_write()
.map(FallbackRwLockWriteGuard::RwLock)
.or_else(|_| Ok(FallbackRwLockWriteGuard::Fallback(Box::new(fallback()))))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this fallback closure is unlikely to change once the FallbackRwLock is created, you could even set the fallback closure in the constructor (assuming it's not FnOnce)

You could also define your own FallbackRwLock trait that comes with a default implementation for try_write_or, and uses required implementations for fallback() and try_write(). This would then allow for having different off-the-shelf fallback clients. If you also add a client() fn to the trait, you could then have a default fallback() implementation of just cloning the returned client()

@tkporter
Copy link
Collaborator Author

tkporter commented Nov 9, 2023

No longer relevant 😭

@tkporter tkporter closed this Nov 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants