mirror of
https://github.com/feschber/lan-mouse.git
synced 2026-04-22 03:03:18 +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,5 +1,11 @@
|
||||
use mio::event::Source;
|
||||
use std::{error::Error, vec::Drain};
|
||||
use std::error::Error;
|
||||
|
||||
#[cfg(unix)]
|
||||
use std::{io, os::fd::RawFd, vec::Drain};
|
||||
|
||||
#[cfg(unix)]
|
||||
use tokio::io::unix::AsyncFd;
|
||||
|
||||
use crate::{client::{ClientHandle, ClientEvent}, event::Event};
|
||||
use crate::backend::producer;
|
||||
|
||||
@@ -49,15 +55,24 @@ pub fn create() -> Result<Box<dyn EventProducer>, Box<dyn Error>> {
|
||||
}
|
||||
}
|
||||
|
||||
pub trait EventProducer: Source {
|
||||
pub trait EventProducer {
|
||||
|
||||
/// notify event producer of configuration changes
|
||||
fn notify(&mut self, event: ClientEvent);
|
||||
|
||||
/// release mouse
|
||||
fn release(&mut self);
|
||||
|
||||
/// unix only
|
||||
#[cfg(unix)]
|
||||
fn get_async_fd(&self) -> io::Result<AsyncFd<RawFd>>;
|
||||
|
||||
/// read an event
|
||||
/// this function must be invoked to retrieve an Event after
|
||||
/// the eventfd indicates a pending Event
|
||||
#[cfg(unix)]
|
||||
fn read_events(&mut self) -> Drain<(ClientHandle, Event)>;
|
||||
|
||||
/// release mouse
|
||||
fn release(&mut self);
|
||||
#[cfg(not(unix))]
|
||||
fn get_wait_channel(&mut self) -> Option<tokio::sync::mpsc::Receiver<(ClientHandle, Event)>>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user