-
Notifications
You must be signed in to change notification settings - Fork 23
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
Deconstructing thread::scope
#120
base: thread-spawn-send-arc-mutex
Are you sure you want to change the base?
Conversation
The part discussing covariance-contravariance will be in a separate deck |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another great deck. Loved it. Just some very minor notes.
* `F: for<'scope> FnOnce(&'scope Scope<'scope, 'env>) -> T` | ||
* `'scope` is a *Higher-Rank Trait Bound* - it describes *all possible* lifetimes that closure can observe | ||
* `fn scope<'env, F, T>(f: F) -> T` | ||
* the function observes *some* lifetime `'env` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* the function observes *some* lifetime `'env` | |
* the function observes *some* lifetime `'env` |
In the lifetimes deck we tried to distinguish between a lifetime (which is a property of a value, marking the time between its creation and its destruction as observed at compile-time), and a lifetime tag/annotation/specifier which is what we add to references to tag or annotate the lifetime of the value they refer to so we can tag/annotate other references as having a must-not-outlive relationship.
left_sum = left.iter().sum(); | ||
}); | ||
// ERROR: closure may outlive the current function | ||
let mut right_sum = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I prefer having examples which compile and run, but where the 'bad code' is commented out.
} | ||
``` | ||
|
||
## How `scope` function waits for all threads to finish? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
## How `scope` function waits for all threads to finish? | |
## How does `fn scope()` wait for all threads to finish? |
} | ||
} | ||
``` | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Links to stdlib source code here would be neat.
Co-authored-by: Jonathan Pallant <[email protected]>
ee0a280
to
29a65a6
Compare
2e15439
to
37dc913
Compare
d0d6848
to
d029d6e
Compare
Making this PR against
thread::spawn
branch to better visualize the diff