1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-07-01 11:32:48 -05:00

Only run one toplevel callback per event loop iteration.

This change attempts to reinstate as a universal property something
which was sporadically true of the ad-hockery that came before
toplevel callbacks: that if there's a _very long_ queue of things to
be done through the callback mechanism, the doing of them will be
interleaved with re-checks of other event sources, which might (e.g.)
cause a flag to be set which makes the next callback decide not to do
anything after all.

[originally from svn r10040]
This commit is contained in:
Simon Tatham
2013-09-15 14:05:31 +00:00
parent 043a762b5f
commit 5c4ce2fadf
8 changed files with 99 additions and 47 deletions

View File

@ -1403,11 +1403,16 @@ void timer_change_notify(unsigned long next);
* top-level event loop. However, if a front end doesn't have control
* over its own event loop (e.g. because it's using GTK) then it can
* instead request notifications when a callback is available, so that
* it knows to ask its delegate event loop to do the same thing.
* it knows to ask its delegate event loop to do the same thing. Also,
* if a front end needs to know whether a callback is pending without
* actually running it (e.g. so as to put a zero timeout on a select()
* call) then it can call toplevel_callback_pending(), which will
* return true if at least one callback is in the queue.
*/
typedef void (*toplevel_callback_fn_t)(void *ctx);
void queue_toplevel_callback(toplevel_callback_fn_t fn, void *ctx);
void run_toplevel_callbacks(void);
int toplevel_callback_pending(void);
typedef void (*toplevel_callback_notify_fn_t)(void *frontend);
void request_callback_notifications(toplevel_callback_notify_fn_t notify,