pub type ThreadFnPtr = dyn Fn(Box<dyn Thread>, Option<ThreadParam>) -> Result<ThreadParam> + Send + Sync + 'static;Expand description
Thread callback function pointer type.
Thread callbacks receive a boxed thread handle and optional parameter, and can return an updated parameter value.
§Parameters
Box<dyn Thread>- Handle to the thread itself (for self-reference)Option<ThreadParam>- Optional type-erased parameter passed at spawn time
§Returns
Result<ThreadParam> - Updated parameter or error
§Trait Bounds
The function must be Send + Sync + 'static to be safely used across
thread boundaries and to live for the duration of the thread.
§Examples
ⓘ
use osal_rs::os::{Thread, ThreadParam};
use std::sync::Arc;
let callback: Box<ThreadFnPtr> = Box::new(|thread, param| {
if let Some(p) = param {
if let Some(count) = p.downcast_ref::<u32>() {
println!("Count: {}", count);
}
}
Ok(Arc::new(0u32))
});