mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 16:24:46 +00:00
Rollup merge of #52759 - stjepang:impl-send-sync-for-joinhandle, r=TimNN
Impl Send & Sync for JoinHandle This is just a cosmetic change - it slightly relaxes and clarifies the public API without effectively promising any new guarantees. Currently we have [these auto trait implementations](https://doc.rust-lang.org/nightly/std/thread/struct.JoinHandle.html#synthetic-implementations): ```rust impl<T: Send> Send for JoinHandle<T> {} impl<T: Sync> Sync for JoinHandle<T> {} ``` Bound `T: Send` doesn't make much sense because `JoinHandle<T>` can be created only when `T: Send`. Note that [`JoinHandle::<T>::join`](https://doc.rust-lang.org/nightly/std/thread/struct.JoinHandle.html#method.join) doesn't require `T: Send` so why should the `Send` impl? And the `Sync` impl doesn't need `T: Sync` because `JoinHandle<T>` cannot even share `T` - it can only send it to the thread that calls `join`.
This commit is contained in:
commit
b326319f15
@ -1276,6 +1276,11 @@ impl<T> JoinInner<T> {
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub struct JoinHandle<T>(JoinInner<T>);
|
||||
|
||||
#[stable(feature = "joinhandle_impl_send_sync", since = "1.29.0")]
|
||||
unsafe impl<T> Send for JoinHandle<T> {}
|
||||
#[stable(feature = "joinhandle_impl_send_sync", since = "1.29.0")]
|
||||
unsafe impl<T> Sync for JoinHandle<T> {}
|
||||
|
||||
impl<T> JoinHandle<T> {
|
||||
/// Extracts a handle to the underlying thread.
|
||||
///
|
||||
|
Loading…
Reference in New Issue
Block a user