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

What happens when a HazardPointer tries to protect a new pointer without first resetting protection? #28

Open
anko opened this issue Mar 20, 2022 · 1 comment

Comments

@anko
Copy link
Contributor

anko commented Mar 20, 2022

let guard = HazardPointer::new();
let ptr1 = guard.protect_ptr(atomic1);
let ptr2 = guard.protect_ptr(atomic2); // ①
guard.reset_protection(); // ②

What does ① do? Does it drop protection for ptr1 and begin protecting ptr2? Or does it fail every time because reset_protection wasn't called in between? I think the documentation doesn't currently explicitly state this.

Similarly, I can imagine multiple things ② might do.

@jonhoo
Copy link
Owner

jonhoo commented Mar 20, 2022

The former — protecting a new pointer stops protecting the old pointer. A given hazard pointer can only protect at most one pointer at the time. I totally agree this should be explicit in the documentation!

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