bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#14820: 24.3; elisp manual: How to write good idle timer worker funct


From: Lars Ingebrigtsen
Subject: bug#14820: 24.3; elisp manual: How to write good idle timer worker functions?
Date: Wed, 26 Jan 2022 18:41:41 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

Phil Sainty <psainty@orcon.net.nz> writes:

> There is a substantial amount of work to perform 'in the background',
> taking (in total) in excess of 10 seconds to complete, and also
> needing to be run on a semi-regular basis, so making the user wait
> each time is out of the question. I wish to perform the work in idle
> time, as quickly as possible, but without disrupting the user.
>
> The work can be broken down into a queue of small items, each of which
> takes a fraction of a second to complete.

[...]

> The quote above indicates that `input-pending-p' is not sufficient to
> detect all kinds of pending activity, but it doesn't suggest other
> options.

(I'm going through old bug reports that unfortunately weren't resolved
at the time.)

I think that these days, you'd probably implement this using Emacs
threads, but I think the general advice in that node is still sound --
if you're doing something that takes a long time from an idle hook, you
should instead schedule a new idle timer (with a very short timeout)
instead of trying to use `pending-input-p' and `sit-for'.

So I'm not sure whether there's anything more to do in this bug report?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





reply via email to

[Prev in Thread] Current Thread [Next in Thread]