The main loop body was originally all written inline. There's now
separate functions for each of the actions the loop handles including
channel events, pty reading, and pty writing. There's also helper
functions on State for managing the write list.
The `EventLoop` and its `State` are returned when joining with the
thread it spawns. This will potentially be helpful once config reloading
is introduced.