Skip to main content

ThreadSimpleFnPtr

Type Alias ThreadSimpleFnPtr 

Source
pub type ThreadSimpleFnPtr = dyn Fn() + Send + Sync + 'static;
Expand description

Simple thread function pointer type without parameters.

Used for basic thread functions that don’t need access to the thread handle or parameters. This is the simplest form of thread callback.

§Trait Bounds

The function must be Send + Sync + 'static to be safely used in a multi-threaded environment.

§Examples

use osal_rs::os::Thread;

let mut thread = Thread::new("simple", 1024, 1);
thread.spawn_simple(|| {
    loop {
        println!("Hello from thread!");
        System::delay(1000);
    }
}).unwrap();