basic example of threaded communication
This commit is contained in:
parent
2611de9b2b
commit
ea48484fc2
1 changed files with 17 additions and 5 deletions
|
@ -125,13 +125,25 @@ fn test_updating() {
|
||||||
assert_eq!(stream_state.scene_is_augmented, true);
|
assert_eq!(stream_state.scene_is_augmented, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
#[test]
|
#[test]
|
||||||
fn can_run_in_thread() {
|
fn can_run_in_thread() {
|
||||||
let (tx, rx) = mpsc::channel();
|
let (tx, rx) = mpsc::channel();
|
||||||
|
|
||||||
thread::spawn(move || {
|
let rx_thread = thread::spawn(move || {
|
||||||
tx
|
let mut stream_state = s_s::stream_states_class::StreamStates::new();
|
||||||
});
|
for received in rx {
|
||||||
|
assert_eq!(received, s_s::stream_states_class::StateUpdate::StreamRunning(true));
|
||||||
|
stream_state = stream_state.update(received);
|
||||||
|
assert_eq!(stream_state.stream_running, true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
tx.send(s_s::stream_states_class::StateUpdate::StreamRunning(true)).unwrap();
|
||||||
|
let result = rx_thread.join();
|
||||||
|
match result {
|
||||||
|
Ok(_) => return,
|
||||||
|
Err(_) => panic!(),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
Loading…
Reference in a new issue