Skip to content

Commit

Permalink
Pass function for Thread as Send to Thread::imp
Browse files Browse the repository at this point in the history
  • Loading branch information
raoulstrackx committed Jun 4, 2024
1 parent 8943103 commit 92b604f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions std/src/thread/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,8 @@ impl Builder {
let main = Box::new(main);
// SAFETY: dynamic size and alignment of the Box remain the same. See below for why the
// lifetime change is justified.
let main = unsafe { Box::from_raw(Box::into_raw(main) as *mut (dyn FnOnce() + 'static)) };
let main =
unsafe { Box::from_raw(Box::into_raw(main) as *mut (dyn FnOnce() + Send + 'static)) };

Ok(JoinInner {
// SAFETY:
Expand Down Expand Up @@ -1544,7 +1545,7 @@ struct Packet<'scope, T> {
// The type `T` should already always be Send (otherwise the thread could not
// have been created) and the Packet is Sync because all access to the
// `UnsafeCell` synchronized (by the `join()` boundary), and `ScopeData` is Sync.
unsafe impl<'scope, T: Sync> Sync for Packet<'scope, T> {}
unsafe impl<'scope, T: Send> Sync for Packet<'scope, T> {}

impl<'scope, T> Drop for Packet<'scope, T> {
fn drop(&mut self) {
Expand Down

0 comments on commit 92b604f

Please sign in to comment.