mirror of
https://github.com/feschber/lan-mouse.git
synced 2026-03-17 18:20:54 +03:00
use local-channel instead of tokio sync channel (#179)
this avoids the mutex overhead in tokio
This commit is contained in:
committed by
GitHub
parent
19c2c4327f
commit
e7a1d72149
@@ -1,10 +1,8 @@
|
||||
use local_channel::mpsc::{Receiver, Sender};
|
||||
use std::net::SocketAddr;
|
||||
|
||||
use lan_mouse_proto::ProtoEvent;
|
||||
use tokio::{
|
||||
sync::mpsc::{Receiver, Sender},
|
||||
task::JoinHandle,
|
||||
};
|
||||
use tokio::task::JoinHandle;
|
||||
|
||||
use crate::{
|
||||
client::{ClientHandle, ClientManager},
|
||||
@@ -140,7 +138,7 @@ async fn handle_incoming_event(
|
||||
match (event, addr) {
|
||||
(ProtoEvent::Pong, _) => { /* ignore pong events */ }
|
||||
(ProtoEvent::Ping, addr) => {
|
||||
let _ = sender_tx.send((ProtoEvent::Pong, addr)).await;
|
||||
let _ = sender_tx.send((ProtoEvent::Pong, addr));
|
||||
}
|
||||
(ProtoEvent::Leave(_), _) => emulate.release_keys(handle).await?,
|
||||
(ProtoEvent::Ack(_), _) => server.set_state(State::Sending),
|
||||
@@ -148,7 +146,6 @@ async fn handle_incoming_event(
|
||||
server.set_state(State::Receiving);
|
||||
sender_tx
|
||||
.send((ProtoEvent::Ack(0), addr))
|
||||
.await
|
||||
.expect("no channel")
|
||||
}
|
||||
(ProtoEvent::Input(e), _) => {
|
||||
|
||||
Reference in New Issue
Block a user