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

try_take #6

Closed
marvin-j97 opened this issue Jul 24, 2024 · 2 comments
Closed

try_take #6

marvin-j97 opened this issue Jul 24, 2024 · 2 comments

Comments

@marvin-j97
Copy link
Contributor

Is it possible for guardian to implement something like Mutex::try_lock (try_take?), that doesn't block the thread if it can't take the mutex immediately? I have a situation where I have multiple mutexes that may or may not be blocked, and I want to iterate through them to find an open lock. With guardian that is currently not possible, but it would be nice to get the lifetime-free lock guard.

@jonhoo
Copy link
Owner

jonhoo commented Jul 27, 2024

Hmm, yes, I think that should be doable! You'd just want a variant of

macro_rules! take {

That calls try_lock and returns an Option. I'm a bit short on time at the moment, but would be happy to review a PR!

@marvin-j97
Copy link
Contributor Author

#7

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

2 participants