mirror of
https://github.com/feschber/lan-mouse.git
synced 2026-04-23 15:53:19 +03:00
Async (#30)
- manual eventloop now replaced by asycn-await using the tokio runtime - dns no longer blocks the event loop - simplifies logic - makes xdg-desktop-portal easier to integrate
This commit is contained in:
committed by
GitHub
parent
d4d6f05802
commit
ab2514e508
@@ -1,8 +1,4 @@
|
||||
use std::vec::Drain;
|
||||
|
||||
use mio::{Token, Registry};
|
||||
use mio::event::Source;
|
||||
use std::io::Result;
|
||||
use tokio::sync::mpsc::{self, Receiver, Sender};
|
||||
|
||||
use crate::{
|
||||
client::{ClientHandle, ClientEvent},
|
||||
@@ -11,48 +7,24 @@ use crate::{
|
||||
};
|
||||
|
||||
pub struct WindowsProducer {
|
||||
pending_events: Vec<(ClientHandle, Event)>,
|
||||
_tx: Sender<(ClientHandle, Event)>,
|
||||
rx: Option<Receiver<(ClientHandle, Event)>>,
|
||||
}
|
||||
|
||||
impl Source for WindowsProducer {
|
||||
fn register(
|
||||
&mut self,
|
||||
_registry: &Registry,
|
||||
_token: Token,
|
||||
_interests: mio::Interest,
|
||||
) -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn reregister(
|
||||
&mut self,
|
||||
_registry: &Registry,
|
||||
_token: Token,
|
||||
_interests: mio::Interest,
|
||||
) -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn deregister(&mut self, _registry: &Registry) -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
impl EventProducer for WindowsProducer {
|
||||
fn notify(&mut self, _: ClientEvent) { }
|
||||
|
||||
fn read_events(&mut self) -> Drain<(ClientHandle, Event)> {
|
||||
self.pending_events.drain(..)
|
||||
}
|
||||
|
||||
fn release(&mut self) { }
|
||||
|
||||
fn get_wait_channel(&mut self) -> Option<mpsc::Receiver<(ClientHandle, Event)>> {
|
||||
self.rx.take()
|
||||
}
|
||||
}
|
||||
|
||||
impl WindowsProducer {
|
||||
pub(crate) fn new() -> Self {
|
||||
Self {
|
||||
pending_events: vec![],
|
||||
}
|
||||
let (_tx, rx) = mpsc::channel(1);
|
||||
let rx = Some(rx);
|
||||
Self { _tx, rx }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user