mirror of
https://github.com/feschber/lan-mouse.git
synced 2026-04-12 13:51:28 +03:00
simplify
This commit is contained in:
@@ -193,13 +193,13 @@ impl Server {
|
|||||||
log::debug!("handled frontend request");
|
log::debug!("handled frontend request");
|
||||||
}
|
}
|
||||||
_ = self.notifies.frontend_event_pending.notified() => {
|
_ = self.notifies.frontend_event_pending.notified() => {
|
||||||
let events = self
|
loop {
|
||||||
.pending_frontend_events
|
let event = self.pending_frontend_events.borrow_mut().pop_front();
|
||||||
.borrow_mut()
|
if let Some(event) = event {
|
||||||
.drain(..)
|
frontend.broadcast(event).await;
|
||||||
.collect::<Vec<_>>();
|
} else {
|
||||||
for event in events {
|
break;
|
||||||
frontend.broadcast(event).await;
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
_ = self.notifies.dns_request_pending.notified() => {
|
_ = self.notifies.dns_request_pending.notified() => {
|
||||||
@@ -561,12 +561,11 @@ fn handle_frontend_stream(
|
|||||||
cancel: CancellationToken,
|
cancel: CancellationToken,
|
||||||
#[cfg(unix)] stream: ReadHalf<UnixStream>,
|
#[cfg(unix)] stream: ReadHalf<UnixStream>,
|
||||||
#[cfg(windows)] stream: ReadHalf<TcpStream>,
|
#[cfg(windows)] stream: ReadHalf<TcpStream>,
|
||||||
request_channel: Sender<FrontendRequest>,
|
request_tx: Sender<FrontendRequest>,
|
||||||
) -> JoinHandle<()> {
|
) -> JoinHandle<()> {
|
||||||
let tx = request_channel.clone();
|
|
||||||
tokio::task::spawn_local(async move {
|
tokio::task::spawn_local(async move {
|
||||||
tokio::select! {
|
tokio::select! {
|
||||||
_ = listen_frontend(tx, stream) => {},
|
_ = listen_frontend(request_tx, stream) => {},
|
||||||
_ = cancel.cancelled() => {},
|
_ = cancel.cancelled() => {},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user