Skip to content

Commit

Permalink
test: make the other_thread example noop on other platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Jul 10, 2022
1 parent 897795e commit cff4ef4
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions examples/other_thread.rs
Original file line number Diff line number Diff line change
@@ -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();
Expand All @@ -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");
}

0 comments on commit cff4ef4

Please sign in to comment.