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

Deconstructing thread::scope #120

Open
wants to merge 4 commits into
base: thread-spawn-send-arc-mutex
Choose a base branch
from

Conversation

listochkin
Copy link
Member

Making this PR against thread::spawn branch to better visualize the diff

@listochkin
Copy link
Member Author

The part discussing covariance-contravariance will be in a separate deck

Copy link
Member

@jonathanpallant jonathanpallant left a 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`
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* 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;
Copy link
Member

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?
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
## How `scope` function waits for all threads to finish?
## How does `fn scope()` wait for all threads to finish?

}
}
```

Copy link
Member

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.

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

Successfully merging this pull request may close these issues.

2 participants