Skip to main content

ThreadParam

Type Alias ThreadParam 

Source
pub type ThreadParam = Arc<dyn Any + Send + Sync>;
Expand description

Type-erased parameter that can be passed to thread callbacks.

Allows passing arbitrary data to thread functions in a thread-safe manner. The parameter is wrapped in an Arc for safe sharing across thread boundaries and can be downcast to its original type using downcast_ref().

§Thread Safety

The inner type must implement Any + Send + Sync to ensure it can be safely shared between threads.

§Examples

use std::sync::Arc;
use osal_rs::traits::ThreadParam;

// Create a parameter
let param: ThreadParam = Arc::new(42u32);

// In the thread callback, downcast to access
if let Some(value) = param.downcast_ref::<u32>() {
    println!("Received: {}", value);
}

Aliased Type§

pub struct ThreadParam { /* private fields */ }