]>
git.proxmox.com Git - pve-lxc-syscalld.git/blob - src/reactor.rs
2 use std
::os
::unix
::io
::RawFd
;
3 use std
::sync
::{mpsc, Arc}
;
4 use std
::thread
::JoinHandle
;
6 use crate::epoll
::Epoll
;
8 pub struct AssertSync
<T
>(pub T
);
9 unsafe impl<T
> Sync
for AssertSync
<T
> {}
13 removals
: AssertSync
<mpsc
::Sender
<RawFd
>>,
14 thread
: JoinHandle
<()>,
18 pub fn new() -> io
::Result
<Self> {
19 let epoll
= Arc
::new(Epoll
::new()?
);
21 let (send_remove
, recv_remove
) = mpsc
::channel();
23 let handle
= std
::thread
::spawn({
24 let epoll
= Arc
::clone(&epoll
);
25 move || Self::thread_main(epoll
, recv_remove
)
30 removals
: AssertSync(send_remove
),
35 fn thread_main(epoll
: Arc
<Epoll
>, removals
: mpsc
::Receiver
<RawFd
>) {