Eliminating Timeout #3984
Replies: 2 comments
-
Hmm... this is getting interesting. Consider the default config: set mail_check = 5
set mail_check_stats_interval = 60
set imap_keep_alive = 300
set pop_check_interval = 60 Every 5s do a quick check for new mail in all mailboxes. Sounds good until you consider the default for set timeout = 600 This means all the other checks no occur at 10 minute intervals. The Event Loops in Index and Pager assume that when Eliminating
They're currently checked in |
Beta Was this translation helpful? Give feedback.
-
Completed in 0cf1ab9 |
Beta Was this translation helpful? Give feedback.
-
Current State
NeoMutt uses
getch()
to get a keypress from the user.$timeout
determines how long ncurses should wait for a response.If that timeout is reached, then
OP_TIMEOUT
is returned to the caller, e.g. Index.The Index's Event Loop can now do some background tasks, like checking for new mail.
But... there are lots of dialogs.
NeoMutt wants to check for new mail in the Index, Pager and Browser, created duplicated code.
Also, IMAP doesn't want its connection to timeout -- more important than the new mail checks.
To make sure that this happens, wherever the user happens to be, means some real ugliness.
Source: graphviz svg
dlg_index()
- Index Event Loop wants an eventkm_dokey_event()
- It will be interpreted usingMENU_INDEX
mutt_getch()
- Check for queued keys/macrosgetch()
- Get a character from the user (ncurses)mutt_getch()
has a lot to do.It handles the key and macro queue,
SIGINT
(Ctrl-C) and the Abort Key (Ctrl-G).If inotify is enabled (Linux only), then it's given a chance to poll for updates.
inotify doesn't belong here.
km_dokey_event()
has a lot to do, too.Its main job is to convert keys d into functions
<delete>
.This involves a looking in global tables (see also #3916).
There's also some magic to lookup macros.
$timeout
is handled here.It determines how long ncurses blocks waiting for a keypress.
It also calls
imap_keep_alive()
.This really doesn't belong here.
Who Needs the Timeout?
There are four users that need a timeout.
They need to be called regardless of which dialog the user is in.
Ideally, they want to be called when nothing else is happening.
timeout-hook
Anything else, like redrawing the screen should be triggered by other events.
A Global Solution
My solution is a global timeout notification.
In
mutt_getch()
, the curses timeout would be set to 1 second.If ncurses returns
ERR
(no key waiting), then a notification gets sent.Each recipient would register an observer.
IMAP can handle its own timing for the keep alive message.
Checking for new mail currently happens in the Index, Pager and Browser.
Making it happen globally, means changing the
new_mail_command
to respond to events.The
timeout-hook
already happens at a global level -- unaware of the current Mailbox.inotify doesn't involve the keys and communicates via global variables, so using an observer is easy.
Beta Was this translation helpful? Give feedback.
All reactions