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

use scoped threads to take away the 'static limitation #3

Open
QuietMisdreavus opened this issue Nov 5, 2017 · 2 comments
Open

use scoped threads to take away the 'static limitation #3

QuietMisdreavus opened this issue Nov 5, 2017 · 2 comments

Comments

@QuietMisdreavus
Copy link
Owner

Right now the only reason par_fold needs Self: 'static, T: 'static is because it uses plain thread::spawn for its worker threads, despite assuming they'll all be finished by the time it returns. Let's codify that and use some scoped threads instead.

For ParMap i bet it'll be a bit more difficult, since it'll need to hang onto the thread handles, but it's probably workable. Just need to make sure it can cancel the threads on Drop instead of just waiting for the whole map to finish.

@jrmuizel
Copy link

jrmuizel commented Dec 6, 2017

What if mem::forget is called instead of Drop?

@QuietMisdreavus
Copy link
Owner Author

If mem::forget is called on a ParMap (when switched to scoped threads)? Then i guess you have a bigger problem on your hands. I'd probably put a lifetime parameter on it to have some kind of indicator for it, but honestly the question around forget in the first place seems eerily similar to discussions that already happened a couple years ago when thread::scoped got taken out of the standard library. Any problem with deliberately leaking a scoped thread handle in the first place also applies to the hypothetical ParMap, since it would be holding some.

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