Skip to content

Commit 7671ee7

Browse files
authored
Add + Send to create_thread's function argument. (#87)
It is, after all, sent to a different thread.
1 parent f6d84fb commit 7671ee7

7 files changed

Lines changed: 11 additions & 9 deletions

File tree

src/arch/aarch64.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ pub(super) unsafe fn clone(
144144
parent_tid: *mut RawPid,
145145
newtls: *mut c_void,
146146
child_tid: *mut RawPid,
147-
fn_: *mut Box<dyn FnOnce() -> Option<Box<dyn Any>>>,
147+
fn_: *mut Box<dyn FnOnce() -> Option<Box<dyn Any>> + Send>,
148148
) -> isize {
149149
let r0;
150150
asm!(

src/arch/arm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ pub(super) unsafe fn clone(
144144
parent_tid: *mut RawPid,
145145
newtls: *mut c_void,
146146
child_tid: *mut RawPid,
147-
fn_: *mut Box<dyn FnOnce() -> Option<Box<dyn Any>>>,
147+
fn_: *mut Box<dyn FnOnce() -> Option<Box<dyn Any>> + Send>,
148148
) -> isize {
149149
let r0;
150150
asm!(

src/arch/riscv64.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ pub(super) unsafe fn clone(
144144
parent_tid: *mut RawPid,
145145
newtls: *mut c_void,
146146
child_tid: *mut RawPid,
147-
fn_: *mut Box<dyn FnOnce() -> Option<Box<dyn Any>>>,
147+
fn_: *mut Box<dyn FnOnce() -> Option<Box<dyn Any>> + Send>,
148148
) -> isize {
149149
let r0;
150150
asm!(

src/arch/x86.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ pub(super) unsafe fn clone(
149149
parent_tid: *mut RawPid,
150150
newtls: *mut c_void,
151151
child_tid: *mut RawPid,
152-
fn_: *mut Box<dyn FnOnce() -> Option<Box<dyn Any>>>,
152+
fn_: *mut Box<dyn FnOnce() -> Option<Box<dyn Any>> + Send>,
153153
) -> isize {
154154
let mut gs: u32 = 0;
155155
asm!("mov {0:x}, gs", inout(reg) gs);

src/arch/x86_64.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ pub(super) unsafe fn clone(
147147
parent_tid: *mut RawPid,
148148
child_tid: *mut RawPid,
149149
newtls: *mut c_void,
150-
fn_: *mut Box<dyn FnOnce() -> Option<Box<dyn Any>>>,
150+
fn_: *mut Box<dyn FnOnce() -> Option<Box<dyn Any>> + Send>,
151151
) -> isize {
152152
let r0;
153153
asm!(

src/thread/libc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,13 @@ impl Thread {
6868
///
6969
/// `fn_` is called on the new thread.
7070
pub fn create_thread(
71-
fn_: Box<dyn FnOnce() -> Option<Box<dyn Any>>>,
71+
fn_: Box<dyn FnOnce() -> Option<Box<dyn Any>> + Send>,
7272
stack_size: usize,
7373
guard_size: usize,
7474
) -> io::Result<Thread> {
7575
extern "C" fn start(arg: *mut c_void) -> *mut c_void {
7676
unsafe {
77-
let arg = arg.cast::<Box<dyn FnOnce() -> Option<Box<dyn Any>>>>();
77+
let arg = arg.cast::<Box<dyn FnOnce() -> Option<Box<dyn Any>> + Send>>();
7878
let arg = Box::from_raw(arg);
7979
match arg() {
8080
None => null_mut(),

src/thread/linux_raw.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ pub(super) unsafe fn initialize_main_thread(mem: *mut c_void) {
372372
///
373373
/// `fn_` is called on the new thread.
374374
pub fn create_thread(
375-
fn_: Box<dyn FnOnce() -> Option<Box<dyn Any>>>,
375+
fn_: Box<dyn FnOnce() -> Option<Box<dyn Any>> + Send>,
376376
stack_size: usize,
377377
guard_size: usize,
378378
) -> io::Result<Thread> {
@@ -563,7 +563,9 @@ pub fn create_thread(
563563
/// `fn_` must be valid to call [`Box::from_raw`] on.
564564
///
565565
/// After calling `fn_`, this terminates the thread.
566-
pub(super) unsafe extern "C" fn entry(fn_: *mut Box<dyn FnOnce() -> Option<Box<dyn Any>>>) -> ! {
566+
pub(super) unsafe extern "C" fn entry(
567+
fn_: *mut Box<dyn FnOnce() -> Option<Box<dyn Any>> + Send>,
568+
) -> ! {
567569
let fn_ = Box::from_raw(fn_);
568570

569571
#[cfg(feature = "log")]

0 commit comments

Comments
 (0)