[−][src]Struct rttrust::thread::Thread
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]
name: &str,
entry: ThreadEntry<P::MiddleState>,
parameter: P,
stack_size: u32,
priority: u8,
tick: u32
) -> Option<Thread> where
P: CallbackParameter,
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]
name: &str,
entry: F,
stack_size: u32,
priority: u8,
tick: u32
) -> Option<Thread> where
F: FnOnce(),
F: Send + 'static,
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]
fn get_ptr(&self) -> NonNull<rt_object>
[src]
fn is_systemobject(&self) -> bool
[src]
fn get_type(&self) -> rt_object_class_type
[src]
fn get_name<'a>(&'a self) -> RtNameRef<'a>
[src]
fn is_created(&self) -> bool
[src]
impl Send for Thread
[src]
Auto Trait Implementations
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,