working on stuff
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
3201579daf
commit
8962159b1c
38
src/reactor.rs
Normal file
38
src/reactor.rs
Normal file
@ -0,0 +1,38 @@
|
||||
use std::io;
|
||||
use std::sync::{mpsc, Arc};
|
||||
use std::thread::JoinHandle;
|
||||
|
||||
use crate::epoll::Epoll;
|
||||
|
||||
pub struct AssertSync<T>(pub T);
|
||||
unsafe impl<T> Sync for AssertSync<T> {}
|
||||
|
||||
pub struct Reactor {
|
||||
epoll: Arc<Epoll>,
|
||||
removals: AssertSync<mpsc::Sender<RawFd>>,
|
||||
thread: JoinHandle<()>,
|
||||
}
|
||||
|
||||
impl Reactor {
|
||||
pub fn new() -> io::Error<Self> {
|
||||
let epoll = Arc::new(Epoll::new()?);
|
||||
|
||||
let (send_remove, recv_remove) = mpsc::channel();
|
||||
|
||||
let handle = std::thread::spawn({
|
||||
let epoll = Arc::clone(&epoll);
|
||||
move || Self::thread_main(epoll, recv_remove)
|
||||
});
|
||||
|
||||
Ok(Self {
|
||||
epoll,
|
||||
removals: AssertSync(send_remove),
|
||||
thread: handle,
|
||||
})
|
||||
}
|
||||
|
||||
fn thread_main(epoll: Arc<Epoll>, removals: mpsc::Receiver<RawFd>) {
|
||||
let _ = epoll;
|
||||
let _ = removals;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user