kurtlawrence / papyrus

(Rust) repl
MIT License
439 stars 14 forks source link

High CPU usage #52

Closed kurtlawrence closed 4 years ago

kurtlawrence commented 4 years ago

Possibly related to the upgrade to crossterm 0.14, constant CPU usage is being seen.

kurtlawrence commented 4 years ago

The offending code block is xterm::event::poll(std::time::Duration::from_millis(0)).

https://github.com/kurtlawrence/papyrus/blob/ebad66a2211bdf6d9e77a78013163d57585eb81d/src/run/interface.rs#L30-L44

Removing the polling code and just using the read() method will work on windows, but will not work on linux (at least through wsl). Seems to freeze up the interface.

if xterm::event::read()
    .ok()
    .and_then(|ev| tx.send(ev).ok())
    .is_none()
{
    break;
}