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

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

Re: try-this-for ?


From: tomas
Subject: Re: try-this-for ?
Date: Thu, 18 Jan 2018 10:27:24 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Thu, Jan 18, 2018 at 03:56:44AM +0100, Emanuel Berg wrote:

[...]

> Right, I suspected that... so what I ask for
> perhaps cannot be done because of the very
> architecture? There is no preemption,
> only collaboration?

There be dragons. Or dragons and mad cows.

Up to now, Emacs Lisp's model of concurrency seems to
be explicitly cooperative. The two spots in the manual
to start with ("Special Events" [0] and, in a more
modern Emacs version "Threads" [1] hint at this. Currently
it seems to be a basic limitation of the interpreter,
although the verbiage in [1] suggests that there is an
active will to change that.

So if you want to get "signals" right deep in your
search for the next Mersenne prime, you'll have to
embed some form of "yield" [2] in your calculation.

But if you alre already "yielding" at strategic spots
in your Mersenne quest, you can as well consult your
watch (i.e. give the timer functions a chance to run),
so you don't need signals, threads or other exotica
for that [3].

Believe me, this is the easier part, and if you plan
carefully and develop some sense of aesthetics it comes
about pretty organically. The dragons are elsewhere.

Cows? I never said anything about them, oh, no.

Cheers

[0] 
https://www.gnu.org/software/emacs/manual/html_node/elisp/Special-Events.html#Special-Events
[1] 
http://git.savannah.gnu.org/cgit/emacs.git/tree/doc/lispref/threads.texi?h=emacs-26
[2] https://en.wikipedia.org/wiki/Generator_(computer_programming)
[3] What do I need threads for, then? For one, if you want
   to wield more computing power in one process: remember,
   the box you bought has at least two cores, and each core
   not dedicated to Emacs is one core wasted.

- -- tomás
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iEYEARECAAYFAlpgaHwACgkQBcgs9XrR2kaDXwCdGWfdXn/4Ymm83RKSwzX8/7hl
4IoAn3ZiADkHIlI+YeU2YJV2dj6XdEsw
=3VTm
-----END PGP SIGNATURE-----



reply via email to

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