pub fn create_with_ext(
        proc: &Arc<Process>,
        name: &str,
        ext: impl Any + Send + Sync,
    ) -> ZxResult<Arc<Self>> {
        let thread = Arc::new(Thread {
            base: KObjectBase::with_name(name),
            _counter: CountHelper::new(),
            proc: proc.clone(),
            ext: Box::new(ext),
            exceptionate: Exceptionate::new(ExceptionChannelType::Thread),
            inner: Mutex::new(ThreadInner {
                context: Some(Box::new(UserContext::default())),
                ..Default::default()
            }),
        });
        proc.add_thread(thread.clone())?;
        Ok(thread)
    }
/// Create a new thread with extension info.
///
/// # Example
/// ```
/// # use std::sync::Arc;
/// # use zircon_object::task::*;
/// # kernel_hal::init();
/// let job = Job::root();
/// let proc = Process::create(&job, "proc").unwrap();
/// // create a thread with extension info
/// let thread = Thread::create_with_ext(&proc, "thread", job.clone()).unwrap();
/// // get the extension info
/// let ext = thread.ext().downcast_ref::<Arc<Job>>().unwrap();
/// assert!(Arc::ptr_eq(ext, &job));
/// ```
Create a new thread with extension info.
Create a new thread with extension info .
pub fn create_with_ext(
        proc: &Arc<Process>,
        name: &str,
        ext: impl Any + Send + Sync,
    ) -> ZxResult<Arc<Self>> {
        let thread = Arc::new(Thread {
            base: KObjectBase::with_name(name),
            _counter: CountHelper::new(),
            proc: proc.clone(),
            ext: Box::new(ext),
            exceptionate: Exceptionate::new(ExceptionChannelType::Thread),
            inner: Mutex::new(ThreadInner {
                context: Some(Box::new(UserContext::default())),
                ..Default::default()
            }),
        });
        proc.add_thread(thread.clone())?;
        Ok(thread)
    }
pub fn create_with_ext ( proc : & Arc < Process > , name : & str , ext : impl Any + Send + Sync , ) -> ZxResult < Arc < Self > > { let thread = Arc :: new ( Thread { base : KObjectBase :: with_name ( name ) , _counter : CountHelper :: new ( ) , proc : proc . clone ( ) , ext : Box :: new ( ext ) , exceptionate : Exceptionate :: new ( ExceptionChannelType :: Thread ) , inner : Mutex :: new ( ThreadInner { context : Some ( Box :: new ( UserContext :: default ( ) ) ) , .. Default :: default ( ) } ) , } ) ; proc . add_thread ( thread . clone ( ) ) ? ; Ok ( thread ) }
Create a new thread with extension info.
Create a new thread with extension info .
proc
&Arc<Process>
name
&str
ext
impl Any + Send + Sync
proc
&Arc<Process>
name
&str
ext
impl Any + Send + Sync
example
None
use std::sync::arc;
None
use zircon_object::task::*;
None
kernel_hal::init();
let job = Job::root();
let proc = Process::create(&job, "proc").unwrap();
create a thread with extension info
let thread = Thread::create_with_ext(&proc, "thread", job.clone()).unwrap();
get the extension info
let ext = thread.ext().downcast_ref::>().unwrap();
assert!(Arc::ptr_eq(ext, &job));
```
let job = Job :: root () ; let proc = Process :: create ( &job " proc " ) . unwrap () ; create a thread with extension info let thread = Thread :: create_with_ext ( &proc " thread " job . clone () ) . unwrap () ; get the extension info let ext = thread . ext () . downcast_ref :: > () . unwrap () ; assert! ( Arc :: ptr_eq ( ext &job )) ; ` ` `