diff options
author | Joe Wilm <joe@jwilm.com> | 2016-12-29 21:38:22 -0500 |
---|---|---|
committer | Joe Wilm <joe@jwilm.com> | 2016-12-29 21:38:22 -0500 |
commit | a91a3f2dce121a179a9371cd0ad1e548cf3d7731 (patch) | |
tree | 311f1ee1b60eb9fb11bad3bdee8812d3be5590b8 /src/main.rs | |
parent | b704dafb2420df6f7fca64980a2f52c1a00bcef5 (diff) | |
download | alacritty-a91a3f2dce121a179a9371cd0ad1e548cf3d7731.tar.gz alacritty-a91a3f2dce121a179a9371cd0ad1e548cf3d7731.zip |
Fix pty read sometimes not triggering draw
There was a lot of complexity around the threadsafe `Flag` type and
waking up the event loop. The idea was to prevent unnecessary calls to
the glutin window's wakeup_event_loop() method which can be expensive.
This complexity made it difficult to get synchronization between the pty
reader and the render thread correct. Now, the `dirty` flag on the
terminal is also used to prevent spurious wakeups. It is only changed
when the mutex is held, so race conditions associated with that flag
shouldn't happen.
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/main.rs b/src/main.rs index 0f89aa06..cce55354 100644 --- a/src/main.rs +++ b/src/main.rs @@ -79,7 +79,8 @@ fn run(mut config: Config, options: cli::Options) -> Result<(), Box<Error>> { // This object contains all of the state about what's being displayed. It's // wrapped in a clonable mutex since both the I/O loop and display need to // access it. - let terminal = Arc::new(FairMutex::new(Term::new(display.size().to_owned()))); + let terminal = Term::new(display.size().to_owned()); + let terminal = Arc::new(FairMutex::new(terminal)); // Create the pty // @@ -129,20 +130,20 @@ fn run(mut config: Config, options: cli::Options) -> Result<(), Box<Error>> { // Main display loop loop { // Process input and window events - let (mut terminal, wakeup_request) = processor.process_events(&terminal, display.window()); + let mut terminal = processor.process_events(&terminal, display.window()); // Handle config reloads - let config_updated = config_monitor.as_ref() + config_monitor.as_ref() .and_then(|monitor| monitor.pending_config()) .map(|new_config| { config = new_config; display.update_config(&config); processor.update_config(&config); - true - }).unwrap_or(false); + terminal.dirty = true; + }); // Maybe draw the terminal - if wakeup_request || config_updated { + if terminal.needs_draw() { // Handle pending resize events // // The second argument is a list of types that want to be notified |