fn run_event_thread(connection: Arc<RustConnection>, sender: SyncSender<Event>, log: slog::Logger) {
    loop {
        let event = match connection.wait_for_event() {
            Ok(event) => event,
            Err(err) => {
                // Connection errors are most likely permanent. Thus, exit the thread.
                slog::crit!(log, "Event thread exiting due to connection error {}", err);
                break;
            }
        };
        match sender.send(event) {
            Ok(()) => {}
            Err(_) => {
                // The only possible error is that the other end of the channel was dropped.
                // This happens in X11Source's Drop impl.
                break;
            }
        }
    }
}
/// This thread reads X11 events from the connection and sends them on the channel.
///
/// This is run in an extra thread since sending an X11 request or waiting for the reply to an X11
/// request can both read X11 events from the underlying socket which are then saved in the
/// RustConnection. Thus, readability of the underlying socket is not enough to guarantee we do not
/// miss wakeups.
///
/// This thread will call wait_for_event(). RustConnection then ensures internally to wake us up
/// when an event arrives. So far, this seems to be the only safe way to integrate x11rb with
/// calloop.
This thread reads X11 events from the connection and sends them on the channel.
This is run in an extra thread since sending an X11 request or waiting for the reply to an X11
request can both read X11 events from the underlying socket which are then saved in the
RustConnection. Thus, readability of the underlying socket is not enough to guarantee we do not
miss wakeups.

This thread will call wait_for_event(). RustConnection then ensures internally to wake us up
when an event arrives. So far, this seems to be the only safe way to integrate x11rb with
calloop.
This thread reads X11 events from the connection and sends them on the channel . This is run in an extra thread since sending an X11 request or waiting for the reply to an X11 request can both read X11 events from the underlying socket which are then saved in the RustConnection . Thus readability of the underlying socket is not enough to guarantee we do not miss wakeups . This thread will call wait_for_event () . RustConnection then ensures internally to wake us up when an event arrives . So far this seems to be the only safe way to integrate x11rb with calloop .
fn run_event_thread(connection: Arc<RustConnection>, sender: SyncSender<Event>, log: slog::Logger) {
    loop {
        let event = match connection.wait_for_event() {
            Ok(event) => event,
            Err(err) => {
                // Connection errors are most likely permanent. Thus, exit the thread.
                slog::crit!(log, "Event thread exiting due to connection error {}", err);
                break;
            }
        };
        match sender.send(event) {
            Ok(()) => {}
            Err(_) => {
                // The only possible error is that the other end of the channel was dropped.
                // This happens in X11Source's Drop impl.
                break;
            }
        }
    }
}
fn run_event_thread ( connection : Arc < RustConnection > , sender : SyncSender < Event > , log : slog :: Logger ) { loop { let event = match connection . wait_for_event ( ) { Ok ( event ) => event , Err ( err ) => { // Connection errors are most likely permanent. Thus, exit the thread. slog :: crit ! ( log " " err ) ; break ; } } ; match sender . send ( event ) { Ok ( ( ) ) => { } Err ( _ ) => { // The only possible error is that the other end of the channel was dropped. // This happens in X11Source's Drop impl. break ; } } } }
This thread reads X11 events from the connection and sends them on the channel.
This thread reads X11 events from the connection and sends them on the channel .
connection
Arc<RustConnection>
sender
SyncSender<Event>
log
slog::Logger
connection
Arc<RustConnection>
sender
SyncSender<Event>
log
slog::Logger