pub struct Thread { /* private fields */ }Implementations§
Source§impl Thread
impl Thread
pub fn new_with_to_priority( name: &str, stack_depth: StackType, priority: impl ToPriority, ) -> Self
pub fn new_with_handle_and_to_priority( handle: ThreadHandle, name: &str, stack_depth: StackType, priority: impl ToPriority, ) -> Result<Self>
pub fn get_metadata_from_handle(handle: ThreadHandle) -> ThreadMetadata
pub fn get_metadata(thread: &Thread) -> ThreadMetadata
pub fn wait_notification_with_to_tick( &self, bits_to_clear_on_entry: u32, bits_to_clear_on_exit: u32, timeout_ticks: impl ToTick, ) -> Result<u32>
Trait Implementations§
Source§impl Thread for Thread
impl Thread for Thread
Source§fn spawn<F>(&mut self, param: Option<ThreadParam>, callback: F) -> Result<Self>
fn spawn<F>(&mut self, param: Option<ThreadParam>, callback: F) -> Result<Self>
Spawns a new thread with a callback.
§Important
The callback must be 'static, which means it cannot borrow local variables.
Use move in the closure to transfer ownership of any captured values:
ⓘ
let data = Arc::new(Mutex::new(0));
let thread = Thread::new("my_thread", 4096, 3, move |_thread, _param| {
// Use 'move' to capture 'data' by value
let mut guard = data.lock().unwrap();
*guard += 1;
Ok(Arc::new(()))
});
``Source§fn spawn_simple<F>(&mut self, callback: F) -> Result<Self>
fn spawn_simple<F>(&mut self, callback: F) -> Result<Self>
Spawns a new thread with a simple closure, similar to std::thread::spawn.
This is the recommended way to create threads for most use cases.
§Example
ⓘ
let counter = Arc::new(Mutex::new(0));
let counter_clone = Arc::clone(&counter);
let handle = Thread::spawn_simple("worker", 4096, 3, move || {
let mut num = counter_clone.lock().unwrap();
*num += 1;
}).unwrap();
handle.join(core::ptr::null_mut());fn new(name: &str, stack_depth: StackType, priority: UBaseType) -> Self
fn new_with_handle( handle: ThreadHandle, name: &str, stack_depth: StackType, priority: UBaseType, ) -> Result<Self>
fn delete(&self)
fn suspend(&self)
fn resume(&self)
fn join(&self, _retval: DoublePtr) -> Result<i32>
fn get_metadata(&self) -> ThreadMetadata
fn get_current() -> Self
fn notify(&self, notification: ThreadNotification) -> Result<()>
fn notify_from_isr( &self, notification: ThreadNotification, higher_priority_task_woken: &mut BaseType, ) -> Result<()>
fn wait_notification( &self, bits_to_clear_on_entry: u32, bits_to_clear_on_exit: u32, timeout_ticks: TickType, ) -> Result<u32>
impl Send for Thread
impl Sync for Thread
Auto Trait Implementations§
impl Freeze for Thread
impl !RefUnwindSafe for Thread
impl Unpin for Thread
impl !UnwindSafe for Thread
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more