all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: W. Greenhouse <wgreenhouse-sGOZH3hwPm2sTnJN9+BGXg@public.gmane.org>
To: help-gnu-emacs-mXXj517/zsQ@public.gmane.org
Subject: Re: Multitasking in emacs?
Date: Fri, 20 Jun 2014 07:07:45 +0000	[thread overview]
Message-ID: <87zjh8hxdq.fsf@motoko.kusanagi> (raw)
In-Reply-To: 87zjh8ozuf.fsf@gmx.at

Hi Martin,

Martin <kleinerdrache-RbZlAiThDcE@public.gmane.org> writes:

> Hi there,
>
> When I do a update of the packages, like
>
> M-X list-packages RET U x y
>
> or when I send large emails, emacs seems to stop me from working for the
> time this processes are running.  Is there a way to put this processes
> in the background and working on in other buffers?

Emacs is usually confined to a single thread of execution and does not
[yet] have a general concept of concurrency. Instead it cleverly uses
subprocesses and asynchronous I/O to achieve concurrency-like effects in
some situations.

For talking to external subprocesses and network sockets, Emacs can use
`start-process' to make an asynchronous process, and then receive
buffered output (over pty or pipe) when it's idle, using "process
filters." Elisp programs that use `start-process' can feel almost like
they are running in multiple threads, but if Emacs needs to do a lot of
processing after receiving the subprocess results, that will block the
event loop and the user will have to wait.

There is a concurrency (multithreading as opposed to the async I/O
concept above) branch of Emacs with approximately one person working on
it. There are also some libraries to do async I/O for elisp itself (or
specific tasks in elisp), by spawning extra worker emacsen, including:

- Elnode <http://elnode.org> -- uses a herd of asynchronous Emacsen to
  provide an nginx-like event-driven webserver. Currently powering the
  marmalade-repo.org ELPA repo, among other things.

- async.el <https://github.com/jwiegley/emacs-async> -- simple,
  general-purpose async elisp library that uses similar concepts to
  elnode: a subprocess Emacs is spawned, given an execution environment
  (just the vars and bindings relevant to the calculation) and told to
  eval something. NB: you do have to rewrite your elisp to make use of
  async.el, but one of the proof of concept setups is to allow
  message-mode to send mail in a background job.

- Gnus can do some things asynchronously, by using the Agent
  functionality and emacs --batch. This batch Gnus process can do things
  like automatically download messages and send mail from your queue.
  (info "(gnus) Batching Agents")

- org-mode can run the export functionality asynchronously in a
  subprocess worker Emacs.

With the async I/O idea, there's not yet a way to just tell any
arbitrary elisp function to automatically run in a "background"
subprocess Emacs, because you need to pass it the state relevant to the
job it needs to do.

Hope that helps give you a better idea of what's happening, even if it
doesn't provide an immediate solution. But for the mail issue, perhaps
you could try async.el's smtpmail wrapper or gnus-agent-batch.

--
Best,
WGG




  reply	other threads:[~2014-06-20  7:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-20  6:32 Multitasking in emacs? Martin
2014-06-20  7:07 ` W. Greenhouse [this message]
2014-06-20 13:48   ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87zjh8hxdq.fsf@motoko.kusanagi \
    --to=wgreenhouse-sgozh3hwpm2stnjn9+bgxg@public.gmane.org \
    --cc=help-gnu-emacs-mXXj517/zsQ@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.