diff --git a/src/reactor.rs b/src/reactor.rs new file mode 100644 index 0000000..7cae74d --- /dev/null +++ b/src/reactor.rs @@ -0,0 +1,38 @@ +use std::io; +use std::sync::{mpsc, Arc}; +use std::thread::JoinHandle; + +use crate::epoll::Epoll; + +pub struct AssertSync(pub T); +unsafe impl Sync for AssertSync {} + +pub struct Reactor { + epoll: Arc, + removals: AssertSync>, + thread: JoinHandle<()>, +} + +impl Reactor { + pub fn new() -> io::Error { + 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, removals: mpsc::Receiver) { + let _ = epoll; + let _ = removals; + } +}