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 ;
2
2
use crate :: io;
3
3
use crate :: mem;
4
4
use crate :: ptr;
@@ -18,7 +18,6 @@ const EXITED: usize = 2;
18
18
pub const DEFAULT_MIN_STACK_SIZE : usize = 4096 ;
19
19
20
20
pub struct Thread {
21
- name : Pin < Box < CString > > ,
22
21
id : TaskHandle_t ,
23
22
join_mutex : Arc < Mutex > ,
24
23
state : Arc < AtomicUsize > ,
@@ -29,20 +28,20 @@ unsafe impl Sync for Thread {}
29
28
30
29
impl Thread {
31
30
// 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 ( ) > )
33
32
-> io:: Result < Thread > {
34
33
let join_mutex = Arc :: new ( Mutex :: new ( ) ) ;
35
34
let state = Arc :: new ( AtomicUsize :: new ( RUNNING ) ) ;
36
35
37
36
let arg = box ( join_mutex. clone ( ) , state. clone ( ) , box p) ;
38
37
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 " ) ) ;
40
39
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 } ;
42
41
43
42
let res = xTaskCreate (
44
43
thread_start,
45
- thread . name . as_ptr ( ) ,
44
+ name. as_ptr ( ) ,
46
45
stack as u32 ,
47
46
Box :: into_raw ( arg) as * mut libc:: c_void ,
48
47
5 ,
Original file line number Diff line number Diff line change @@ -494,7 +494,7 @@ impl Builder {
494
494
// returning.
495
495
native : Some ( imp:: Thread :: new (
496
496
#[ cfg( target_os = "freertos" ) ]
497
- my_thread. cname ( ) . map ( |s| s . to_owned ( ) ) ,
497
+ my_thread. cname ( ) ,
498
498
stack_size,
499
499
mem:: transmute :: < Box < dyn FnOnce ( ) + ' a > , Box < dyn FnOnce ( ) + ' static > > ( Box :: new (
500
500
main,
You can’t perform that action at this time.
0 commit comments