diff --git a/examples/other_thread.rs b/examples/other_thread.rs index 44abd96ab..e7fe23736 100644 --- a/examples/other_thread.rs +++ b/examples/other_thread.rs @@ -1,25 +1,34 @@ -// Windows only currently +#[cfg(all(windows, not(target_vendor = "uwp")))] use backtrace::{Backtrace, BacktraceFrame}; +#[cfg(all(windows, not(target_vendor = "uwp")))] use std::os::windows::prelude::AsRawHandle; +#[cfg(all(windows, not(target_vendor = "uwp")))] fn worker() { foo(); } + +#[cfg(all(windows, not(target_vendor = "uwp")))] fn foo() { bar() } + +#[cfg(all(windows, not(target_vendor = "uwp")))] fn bar() { baz() } + +#[cfg(all(windows, not(target_vendor = "uwp")))] fn baz() { println!("Hello from thread!"); // Sleep for simple sync. Can't read thread that has finished running - //std::thread::sleep(std::time::Duration::from_millis(1000)); + std::thread::sleep(std::time::Duration::from_millis(1000)); loop { print!(""); } } +#[cfg(all(windows, not(target_vendor = "uwp")))] fn main() { let thread = std::thread::spawn(|| { worker(); @@ -41,3 +50,8 @@ fn main() { bt.resolve(); println!("{:?}", bt); } + +#[cfg(not(all(windows, not(target_vendor = "uwp"))))] +fn main() { + println!("This example is skipped on non Windows platforms"); +}