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

Implement Worker::is_same_as #1103

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

james7132
Copy link

Currently it's not possible to tell if a Worker and a Stealer point to the same underlying queue. This make it difficult to tell which stealer to remove from a list and you have a local Worker on hand, or skip stealing from when given a global list of stealers. The implementation just forwards to Arc::ptr_eq on the inner buffer. Added a doctest as well.

Copy link
Member

@taiki-e taiki-e left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! I'm positive about adding such a method.

crossbeam-deque/src/deque.rs Outdated Show resolved Hide resolved
/// assert!(!w_1.is_same_as(&s_2));
/// assert!(!w_2.is_same_as(&s_1));
/// ```
pub fn is_same_as(&self, stealer: &Stealer<T>) -> bool {
Copy link
Member

@taiki-e taiki-e Apr 25, 2024

Choose a reason for hiding this comment

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

I don't feel this method name is easy to understand, but I'm not sure what the good name would be.

Copy link
Author

Choose a reason for hiding this comment

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

Not sure if Worker::ptr_eq is better. I can't seem to come up with a better name here either.

Copy link

Choose a reason for hiding this comment

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

How about Worker::donates_to?

@taiki-e taiki-e added crossbeam-deque S-waiting-on-bikeshed Status: Awaiting a decision on trivial things. labels Dec 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crossbeam-deque S-waiting-on-bikeshed Status: Awaiting a decision on trivial things.
Development

Successfully merging this pull request may close these issues.

3 participants