pub struct DThdElement { /* private fields */ }Expand description
动态线程的元素
动态线程的元素中的数据需跨线程共享,因此在定义时需要使用 Arc 进行封装。
Implementations§
source§impl DThdElement
 
impl DThdElement
sourcepub fn name(&self) -> &str
 
pub fn name(&self) -> &str
返回动态线程名字的引用
§示例
use xwrust::xwos::thd;
use libc_print::std_name::println;
let handler = thd::DThdBuilder::new()
    .name("foo".into())
    .spawn(|ele| {
        println!("Thread name: {}", ele.name());
    });sourcepub fn stack_size(&self) -> XwSz
 
pub fn stack_size(&self) -> XwSz
返回动态线程的栈大小
§示例
use xwrust::xwos::thd;
use libc_print::std_name::println;
let handler = thd::DThdBuilder::new()
    .spawn(|ele| {
        println!("Thread stack size: {}", ele.stack_size()); // 将返回默认线程大小
    });sourcepub fn privileged(&self) -> bool
 
pub fn privileged(&self) -> bool
返回动态线程是否具有特权
§示例
use xwrust::xwos::thd;
use libc_print::std_name::println;
let handler = thd::DThdBuilder::new()
    .privileged(true);
    .spawn(|ele| {
        println!("Thread is privileged: {} .", ele.privileged());
    });