added delay to test
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
use std::sync::{Arc, Condvar, Mutex};
|
use std::sync::{Arc, Condvar, Mutex};
|
||||||
|
|
||||||
|
/// Operates similarly to the `oneshot` channel in tokio
|
||||||
pub struct ReturnChannel<T> {
|
pub struct ReturnChannel<T> {
|
||||||
value: Mutex<Option<T>>,
|
value: Mutex<Option<T>>,
|
||||||
condvar: Condvar,
|
condvar: Condvar,
|
||||||
@@ -52,6 +53,7 @@ impl<T> ReturnChannelSender<T> {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
pub use super::*;
|
pub use super::*;
|
||||||
|
use std::time::Duration;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_channel_single_thread() {
|
fn test_channel_single_thread() {
|
||||||
@@ -69,6 +71,7 @@ mod test {
|
|||||||
let (tx, rx) = ReturnChannel::new();
|
let (tx, rx) = ReturnChannel::new();
|
||||||
|
|
||||||
std::thread::spawn(|| {
|
std::thread::spawn(|| {
|
||||||
|
std::thread::sleep(Duration::from_millis(500));
|
||||||
tx.send(42);
|
tx.send(42);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user