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

Nested scopes with lifetime bounds #583

Closed
joshtriplett opened this issue Oct 12, 2020 · 3 comments
Closed

Nested scopes with lifetime bounds #583

joshtriplett opened this issue Oct 12, 2020 · 3 comments

Comments

@joshtriplett
Copy link

I'd like to be able to ask a Scope object for a nested scope whose lifetime is bounded by the lifetime of the outer scope. That would allow a scoped thread to spawn a more narrowly scoped inner thread that can borrow from the outer-scoped thread.

This could look like a method scope on Scope that creates a new Scope with an appropriately bounded lifetime.

@taiki-e
Copy link
Member

taiki-e commented Mar 3, 2022

It seems rust-lang/rust#94559 implements this.

EDIT: sorry, it seems I misunderstood the request.

@m-ou-se
Copy link

m-ou-se commented Mar 3, 2022

I think what @joshtriplett meant is starting an new smaller scope. The PR you mention just removes the need for the argument to the closure, but doesn't provide any new functionality.

@joshtriplett Why doesn't just starting a new crossbeam_utils::thread::scope with the existing function suffice? Does it need to be attached to the existing Scope? Do you have an example?

@joshtriplett
Copy link
Author

When I posted the original request, I had a specific use case that motivated it, but it's been too long and I can no longer reconstruct the specific use case. I'm going to close this.

I'm looking forward to the new standard library scopes.

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

No branches or pull requests

3 participants