Crate for locking by name

Here's another solution using thread::park.

https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=411746fa022c12110839d4bbd810e1ae

1 Like

OK, like this.

https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=dcd4e5bfa637ef94390a2d7a82280971

That's another 2-stage solution. But if there's no other way...

My second post is not a 2-stage solution.

True, but now we're getting into writing a custom CPU dispatcher.

I gather there's no way to do

let lok1 = locks.get("abc");
let _guard1 = lok1.lock();

in one statement.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.