(tx: &Sender<Command>, cmd: Command)
| 72 | } |
| 73 | |
| 74 | fn try_send_loop(tx: &Sender<Command>, cmd: Command) { |
| 75 | match tx.try_send(cmd) { |
| 76 | Ok(_) => {} |
| 77 | Err(tokio::sync::mpsc::error::TrySendError::Full(cmd)) => { |
| 78 | // 通道满了:把发送任务交给 tokio 等待 |
| 79 | let tx_clone = tx.clone(); |
| 80 | tokio::spawn(async move { |
| 81 | if let Err(e) = tx_clone.send(cmd).await { |
| 82 | eprintln!("delay tx send failed: {e:?}"); |
| 83 | } |
| 84 | }); |
| 85 | } |
| 86 | Err(e) => { |
| 87 | eprintln!("try_send other error: {e:?}"); |
| 88 | } |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | pub(crate) struct DelayExecutor { |
| 93 | timer: slint::Timer, |