diff options
author | Matias Linares <matiaslina@openmailbox.org> | 2015-11-22 20:02:10 -0300 |
---|---|---|
committer | Matias Linares <matiaslina@openmailbox.org> | 2015-11-22 20:02:10 -0300 |
commit | 83b7d0cb4f30c95ce6f27d2c0944727d75eb6e5e (patch) | |
tree | 255c9e3f5e0703676382fda1157bdb5daf14bc62 /src/socket/mod.rs | |
parent | 47fc031feeddc955e6c7c43410613c75e3370e96 (diff) | |
download | dotwm-83b7d0cb4f30c95ce6f27d2c0944727d75eb6e5e.tar.gz |
Death to the threads.
All the socket stuff is done syncing it with select calls so we can
get either a X11 event or a Socket event.
Also cleanup the C mess, it's done all in rust now :).
Diffstat (limited to 'src/socket/mod.rs')
-rw-r--r-- | src/socket/mod.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/socket/mod.rs b/src/socket/mod.rs index 804f7ac..e260284 100644 --- a/src/socket/mod.rs +++ b/src/socket/mod.rs @@ -10,6 +10,14 @@ use unix_socket::UnixStream; use dotwm::DotWM; use command::*; +pub fn next_socket_event(rx: &Receiver<UnixStream>) -> Option<UnixStream> { + match rx.try_recv() { + Ok(stream) => Some(stream), + Err(TryRecvError::Empty) => None, + Err(TryRecvError::Disconnected) => panic!("Socket disconnected"), + } +} + /// Listen a socket parsing and executing all the commands. pub fn listen_socket(dotwm: &mut DotWM, bindings: &mut BindingHash, rx: &Receiver<UnixStream>) { loop { |