]> git.proxmox.com Git - pve-lxc-syscalld.git/blame - src/reactor.rs
c_call -> c_result for consistency
[pve-lxc-syscalld.git] / src / reactor.rs
CommitLineData
8962159b 1use std::io;
df560c25 2use std::os::unix::io::RawFd;
8962159b
WB
3use std::sync::{mpsc, Arc};
4use std::thread::JoinHandle;
5
6use crate::epoll::Epoll;
7
8pub struct AssertSync<T>(pub T);
9unsafe impl<T> Sync for AssertSync<T> {}
10
11pub struct Reactor {
12 epoll: Arc<Epoll>,
13 removals: AssertSync<mpsc::Sender<RawFd>>,
14 thread: JoinHandle<()>,
15}
16
17impl Reactor {
df560c25 18 pub fn new() -> io::Result<Self> {
8962159b
WB
19 let epoll = Arc::new(Epoll::new()?);
20
21 let (send_remove, recv_remove) = mpsc::channel();
22
23 let handle = std::thread::spawn({
24 let epoll = Arc::clone(&epoll);
25 move || Self::thread_main(epoll, recv_remove)
26 });
27
28 Ok(Self {
29 epoll,
30 removals: AssertSync(send_remove),
31 thread: handle,
32 })
33 }
34
35 fn thread_main(epoll: Arc<Epoll>, removals: mpsc::Receiver<RawFd>) {
36 let _ = epoll;
37 let _ = removals;
d1b1deab
WB
38 loop {
39 }
8962159b
WB
40 }
41}