File tree Expand file tree Collapse file tree 2 files changed +6
-7
lines changed Expand file tree Collapse file tree 2 files changed +6
-7
lines changed Original file line number Diff line number Diff line change 1- use crate :: ffi:: CString ;
1+ use crate :: ffi:: CStr ;
22use crate :: io;
33use crate :: mem;
44use crate :: ptr;
@@ -18,7 +18,6 @@ const EXITED: usize = 2;
1818pub const DEFAULT_MIN_STACK_SIZE : usize = 4096 ;
1919
2020pub struct Thread {
21- name : Pin < Box < CString > > ,
2221 id : TaskHandle_t ,
2322 join_mutex : Arc < Mutex > ,
2423 state : Arc < AtomicUsize > ,
@@ -29,20 +28,20 @@ unsafe impl Sync for Thread {}
2928
3029impl Thread {
3130 // unsafe: see thread::Builder::spawn_unchecked for safety requirements
32- pub unsafe fn new ( name : Option < CString > , stack : usize , p : Box < dyn FnOnce ( ) > )
31+ pub unsafe fn new ( name : Option < & CStr > , stack : usize , p : Box < dyn FnOnce ( ) > )
3332 -> io:: Result < Thread > {
3433 let join_mutex = Arc :: new ( Mutex :: new ( ) ) ;
3534 let state = Arc :: new ( AtomicUsize :: new ( RUNNING ) ) ;
3635
3736 let arg = box ( join_mutex. clone ( ) , state. clone ( ) , box p) ;
3837
39- let name = Box :: pin ( name. unwrap_or_else ( || CString :: from_vec_unchecked ( b"rust_thread" . to_vec ( ) ) ) ) ;
38+ let name = name. unwrap_or_else ( || CStr :: from_bytes_with_nul_unchecked ( b"\0 " ) ) ;
4039
41- let mut thread = Thread { name , id : ptr:: null_mut ( ) , join_mutex, state } ;
40+ let mut thread = Thread { id : ptr:: null_mut ( ) , join_mutex, state } ;
4241
4342 let res = xTaskCreate (
4443 thread_start,
45- thread . name . as_ptr ( ) ,
44+ name. as_ptr ( ) ,
4645 stack as u32 ,
4746 Box :: into_raw ( arg) as * mut libc:: c_void ,
4847 5 ,
Original file line number Diff line number Diff line change @@ -494,7 +494,7 @@ impl Builder {
494494 // returning.
495495 native : Some ( imp:: Thread :: new (
496496 #[ cfg( target_os = "freertos" ) ]
497- my_thread. cname ( ) . map ( |s| s . to_owned ( ) ) ,
497+ my_thread. cname ( ) ,
498498 stack_size,
499499 mem:: transmute :: < Box < dyn FnOnce ( ) + ' a > , Box < dyn FnOnce ( ) + ' static > > ( Box :: new (
500500 main,
You can’t perform that action at this time.
0 commit comments