Change sys::Thread::new to take the thread entry as Box<dyn FnBox() + 'static>̣
This commit is contained in:
@@ -32,7 +32,8 @@ unsafe impl Send for Thread {}
|
||||
unsafe impl Sync for Thread {}
|
||||
|
||||
impl Thread {
|
||||
pub unsafe fn new<'a>(stack: usize, p: Box<dyn FnBox() + 'a>) -> io::Result<Thread> {
|
||||
// unsafe: see thread::Builder::spawn_unchecked for safety requirements
|
||||
pub unsafe fn new(stack: usize, p: Box<dyn FnBox()>) -> io::Result<Thread> {
|
||||
let p = box p;
|
||||
let mut native: libc::pthread_t = mem::zeroed();
|
||||
let mut attr: libc::pthread_attr_t = mem::zeroed();
|
||||
|
||||
@@ -28,7 +28,8 @@ unsafe impl Send for Thread {}
|
||||
unsafe impl Sync for Thread {}
|
||||
|
||||
impl Thread {
|
||||
pub unsafe fn new<'a>(_stack: usize, p: Box<dyn FnBox() + 'a>) -> io::Result<Thread> {
|
||||
// unsafe: see thread::Builder::spawn_unchecked for safety requirements
|
||||
pub unsafe fn new(_stack: usize, p: Box<dyn FnBox()>) -> io::Result<Thread> {
|
||||
let p = box p;
|
||||
|
||||
let id = cvt(syscall::clone(syscall::CLONE_VM | syscall::CLONE_FS | syscall::CLONE_FILES))?;
|
||||
|
||||
@@ -49,7 +49,8 @@ unsafe fn pthread_attr_setstacksize(_attr: *mut libc::pthread_attr_t,
|
||||
}
|
||||
|
||||
impl Thread {
|
||||
pub unsafe fn new<'a>(stack: usize, p: Box<dyn FnBox() + 'a>)
|
||||
// unsafe: see thread::Builder::spawn_unchecked for safety requirements
|
||||
pub unsafe fn new(stack: usize, p: Box<dyn FnBox()>)
|
||||
-> io::Result<Thread> {
|
||||
let p = box p;
|
||||
let mut native: libc::pthread_t = mem::zeroed();
|
||||
|
||||
@@ -19,7 +19,8 @@ pub struct Thread(Void);
|
||||
pub const DEFAULT_MIN_STACK_SIZE: usize = 4096;
|
||||
|
||||
impl Thread {
|
||||
pub unsafe fn new<'a>(_stack: usize, _p: Box<dyn FnBox() + 'a>)
|
||||
// unsafe: see thread::Builder::spawn_unchecked for safety requirements
|
||||
pub unsafe fn new(_stack: usize, _p: Box<dyn FnBox()>)
|
||||
-> io::Result<Thread>
|
||||
{
|
||||
unsupported()
|
||||
|
||||
@@ -28,7 +28,8 @@ pub struct Thread {
|
||||
}
|
||||
|
||||
impl Thread {
|
||||
pub unsafe fn new<'a>(stack: usize, p: Box<dyn FnBox() + 'a>)
|
||||
// unsafe: see thread::Builder::spawn_unchecked for safety requirements
|
||||
pub unsafe fn new(stack: usize, p: Box<dyn FnBox()>)
|
||||
-> io::Result<Thread> {
|
||||
let p = box p;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user