Spawn a heartbeat thread which sends ticks down the reply channel every second. This lets us implement timeouts without the not yet stable `recv_timeout`.
(replies: Sender<Reply>)
| 114 | /// Spawn a heartbeat thread which sends ticks down the reply channel every second. |
| 115 | /// This lets us implement timeouts without the not yet stable `recv_timeout`. |
| 116 | fn heartbeat_thread(replies: Sender<Reply>) -> thread::JoinHandle<()> { |
| 117 | thread::Builder::new() |
| 118 | .name("heartbeat".to_string()) |
| 119 | .spawn(move || { |
| 120 | file_per_thread_logger::initialize(LOG_FILENAME_PREFIX); |
| 121 | while replies.send(Reply::Tick).is_ok() { |
| 122 | thread::sleep(Duration::from_secs(1)); |
| 123 | } |
| 124 | }) |
| 125 | .unwrap() |
| 126 | } |
| 127 | |
| 128 | /// Spawn a worker thread running tests. |
| 129 | fn worker_thread( |