[][src]Struct rttrust::thread::Thread

#[repr(transparent)]pub struct Thread { /* fields omitted */ }

All methods use immutable self since the safety is guaranteed by rt-thread internal

TODO: thread cleanup and unwind

https://blog.rust-lang.org/inside-rust/2020/02/27/ffi-unwind-design-meeting.html

TODO: thread control

Implementations

impl Thread[src]

pub fn new(thread: &mut rt_thread) -> &Thread[src]

pub fn create<P>(
    name: &str,
    entry: ThreadEntry<P::MiddleState>,
    parameter: P,
    stack_size: u32,
    priority: u8,
    tick: u32
) -> Option<Thread> where
    P: CallbackParameter
[src]

This function will create a thread object and allocate thread object memory and stack.

@param name the name of thread, which shall be unique @param entry the entry function of thread @param parameter the parameter of thread enter function @param stack_size the size of thread stack @param priority the priority of thread @param tick the time slice if there are same priority thread

@return the created thread object

pub fn create_closure<F>(
    name: &str,
    entry: F,
    stack_size: u32,
    priority: u8,
    tick: u32
) -> Option<Thread> where
    F: FnOnce(),
    F: Send + 'static, 
[src]

pub fn current() -> Option<Thread>[src]

This function will return self thread object

@return the self thread object

pub unsafe fn find(name: &str) -> Option<Thread>[src]

This function will find the specified thread.

@param name the name of thread finding

@return the found thread

@note please don't invoke this function in interrupt status.

Safety

The thread returned is shared and could be potenially deleted by other thread later.

pub fn find_locked(name: &str) -> Option<ThreadLocked>[src]

pub fn is_existed(name: &str) -> bool[src]

pub fn startup(&mut self) -> Result<()>[src]

This function will start a thread and put it to system ready queue

@param thread the thread to be started

@return the operation status, RT_EOK on OK, -RT_ERROR on error

pub unsafe fn delete(self) -> Result<()>[src]

This function will delete a thread. The thread object will be removed from thread queue and deleted from system object management in the idle thread.

@param thread the thread to be deleted

@return the operation status, RT_EOK on OK, -RT_ERROR on error

Wanring:

Rust thread has no cleanup function and is not able to unwind. Directly stopping a Rust thread may lead to resoucre leak.

pub fn yield0() -> Result<()>[src]

This function will let current thread yield processor, and scheduler will choose a highest thread to run. After yield processor, the current thread is still in READY state.

@return RT_EOK

pub fn delay(tick: rt_tick_t) -> Result<()>[src]

This function will let current thread delay for some ticks.

@param tick the delay ticks

@return RT_EOK

pub fn mdelay(ms: i32) -> Result<()>[src]

This function will let current thread delay for some milliseconds.

@param ms the delay ms time

@return RT_EOK

pub fn suspend(&mut self) -> Result<()>[src]

This function will suspend the specified thread.

@return the operation status, RT_EOK on OK, -RT_ERROR on error

@note if suspend self thread, after this function call, the rt_schedule() must be invoked.

pub fn resume(&mut self) -> Result<()>[src]

This function will resume a thread and put it to system ready queue.

@param thread the thread to be resumed

@return the operation status, RT_EOK on OK, -RT_ERROR on error

Trait Implementations

impl Debug for Thread[src]

impl Object for Thread[src]

impl Send for Thread[src]

Auto Trait Implementations

impl !Sync for Thread

impl Unpin for Thread

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.