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

Do we need crossbeam-stack? #24

Open
jeehoonkang opened this issue Nov 25, 2017 · 2 comments
Open

Do we need crossbeam-stack? #24

jeehoonkang opened this issue Nov 25, 2017 · 2 comments

Comments

@jeehoonkang
Copy link
Contributor

Currently, the crossbeam crate provides the Treiber stack. In order for crossbeam to be backward-compatible as much as possible, when we're rebasing it on top of crossbeam-epoch, I think we need to implement crossbeam-stack.

It can be just the Treiber stack at first, but maybe in the future, we want to implement the elimination-backoff stack or another more advanced stacks. For now, we can just copy-and-paste the code from crossbeam or coco.

@ghost
Copy link

ghost commented Nov 25, 2017

I'm in favor of moving the stack into crossbeam-stack. I'd also suggest doing some research and writing simple a RFC for it, which should answer the following questions:

  1. In what situations is concurrent stack a useful data structure? How are concurrent stacks typically used, not just in Rust but in other languages as well?
  2. What are examples of implementations of concurrent stacks in other languages?
  3. What methods should a concurrent stack have?

Here are some additional methods I've thought of that might be useful to have in a lock-free stack:

fn swap(&mut self, other: &Stack<T>);
fn merge_from(&self, other: &Stack<T>);
fn drain(&self) -> Stack<T>;
fn extend(&self, other: impl IntoIterator<Item = T>);
fn into_iter() -> impl Iterator<Item = T>;

.NET provides a concurrent stack. Perhaps we could take some ideas for it?
https://msdn.microsoft.com/en-us/library/dd267331(v=vs.110).aspx

And here are some actual uses of TreiberStack on GitHub, although there aren't many:
https://github.com/search?l=Rust&q=crossbeam%3A%3Async%3A%3ATreiberStack&type=Code&utf8=%E2%9C%93

@Amanieu
Copy link

Amanieu commented Nov 25, 2017

I use a variant of the Treiber stack in parking_lot: https://github.com/Amanieu/parking_lot/blob/master/core/src/word_lock.rs#L24

However this is a very low-level and customized implementation and it wouldn't make sense to use a generic data structure implementation from crossbeam there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants