aboutsummaryrefslogtreecommitdiffstats
path: root/pw.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2022-04-29 21:00:53 -0700
committerKaz Kylheku <kaz@kylheku.com>2022-04-29 21:00:53 -0700
commitae7ceffbe451a6264edf7d1354cc9d55df8940b9 (patch)
tree1ed11b5b2fc0bc886c16834295c4bc005b085881 /pw.c
parenteeb7dd244f079f45568896bb2c35b9f0afaaba82 (diff)
downloadpw-ae7ceffbe451a6264edf7d1354cc9d55df8940b9.tar.gz
pw-ae7ceffbe451a6264edf7d1354cc9d55df8940b9.tar.bz2
pw-ae7ceffbe451a6264edf7d1354cc9d55df8940b9.zip
Dynamic priority scheme between TTY and FIFO.
Whenever a character from the TTY are processed, the work bout size (max number of lines processed without polling TTY or time-of-day) is cut in half, so as the user types, the UI quickly becomes more responsive. When TTY activity ceases, the work bout successively grows in size again toward the maximum value to favor more efficient reading.
Diffstat (limited to 'pw.c')
-rw-r--r--pw.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/pw.c b/pw.c
index f6c79fc..e3a2b0a 100644
--- a/pw.c
+++ b/pw.c
@@ -653,7 +653,7 @@ int main(int argc, char **argv)
for (unsigned stat = stat_dirty, hpos = 0,
kbd_state = kbd_cmd, kbd_prev = kbd_cmd, lasttime = ~0U,
- work = 1000, histpos = 0;
+ workbout = 1024, work = workbout, histpos = 0;
kbd_state != kbd_exit ;)
{
int force = 0, nfds = 2, pollms = poll_interval;
@@ -759,7 +759,7 @@ int main(int argc, char **argv)
if (pollms == 0 && !force && work-- > 0)
continue;
- work = 1000;
+ work = workbout;
if (!force)
{
@@ -794,10 +794,14 @@ int main(int argc, char **argv)
drawstatus(columns, stat, curcmd);
}
}
+ work = workbout += workbout / 4;
} else {
if ((pe[0].revents)) {
int ch = getc(tty);
+ if (workbout > 16)
+ work = workbout /= 2;
+
if (ch == ctrl('z')) {
ttyset(ttyfd, &tty_saved);
kill(0, SIGTSTP);
@@ -1049,6 +1053,8 @@ int main(int argc, char **argv)
clrline();
drawstatus(columns, stat, curcmd);
}
+ } else {
+ work = workbout += workbout / 4;
}
}
}