Skip to content

Commit

Permalink
fix: remove 100ms delay on first and subsequent read calls
Browse files Browse the repository at this point in the history
Currently, there is an unnecessary wait with `recv_timeout()` on reader thread which causes reading from pipe to have an inherent 100ms wait time.

Similarly, cache thread also has this issue, where read() calls are served throttled with a 100ms delay
  • Loading branch information
SilverMira authored Jun 27, 2024
1 parent dbbefcd commit 5a8aab1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/pty/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ impl PTYProcess {
// let mut alive = reader_alive_rx.recv_timeout(Duration::from_millis(300)).unwrap_or(true);
// alive = alive && !is_eof(process, conout).unwrap();

while reader_alive_rx.recv_timeout(Duration::from_millis(100)).unwrap_or(true) {
while reader_alive_rx.try_recv().unwrap_or(true) {
if !is_eof(process, conout).unwrap() {
let result = read(4096, true, conout, using_pipes);
reader_out_tx.send(Some(result)).unwrap();
Expand All @@ -378,7 +378,7 @@ impl PTYProcess {

let cache_thread = thread::spawn(move || {
let mut read_buf = OsString::new();
while cache_alive_rx.recv_timeout(Duration::from_millis(100)).unwrap_or(true) {
while cache_alive_rx.try_recv().unwrap_or(true) {
if let Ok(Some((length, blocking))) = cache_req_rx.recv() {
let mut pending_read: Option<OsString> = None;

Expand Down

0 comments on commit 5a8aab1

Please sign in to comment.