unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Phil Sainty <psainty@orcon.net.nz>
To: Daimrod <daimrod@gmail.com>
Cc: 14820@debbugs.gnu.org
Subject: bug#14820: 24.3; elisp manual: How to write good idle timer worker functions?
Date: Sat, 13 Jul 2013 18:38:48 +1200	[thread overview]
Message-ID: <51E0F5F8.10206@orcon.net.nz> (raw)
In-Reply-To: <87ppup2p1z.fsf@tanger.home>

Thanks Greg, that sounds like good stuff in general.

Sadly it's not applicable in my case -- the processing I'm doing
is very much tied to the current running Emacs instance -- but it's
definitely good to know those packages exist for other use cases.

cheers,
-Phil


On 12/07/2013 01:39, Daimrod wrote:
> A bit of background:
> I'm GSoC student working on the XWidget branch and I wanted to add test
> to it. But I've encountered two problems while trying to write "classic"
> ERT tests. One is that since I'm working on the C side on an
> experimental branch, sometimes Emacs crashes. The second problem is that
> some tests needs to be run in a graphical Emacs. So I can't run the
> tests in batch mode to circumvent the first problem.
>
>
> I've wrote a package, emacs-parallel[1], (the API isn't very clean but
> it's good enough for my current needs) to eval some stuff in another
> Emacs process. I've been heavily inspired by emacs-async[2], but I've
> made differents choices:
> - it can start a graphical Emacs (not Batch Mode);
> - it communicates through a Unix socket instead of standard I/O stream
> (because, AFAIK, it is not possible to use them without Batch Mode);
> - you can send data from the remote process while the process isn't
> finished instead of just sending the result of the call;
> - the main entry point is a function, not a macro;
> - it tells you whether the process terminated normally, and if not, what
> happens (exit code or signal number).
> - it handles timeout (you can stop the remote instance after X seconds);
>
> I haven't wrote much doc yet (I've started it monday) so maybe
> emacs-async is a better choice (ATM) if you don't need an graphical
> Emacs or if you don't need to send data without interrupting the remote
> process.
>
> (parallel-start (lambda () (parallel-send 42) (sleep-for 3) 12)
>                  :post-exec (lambda (results _status)
>                               (message "%s" results)))
>
> (emacs-async equivalent)
> (async-start (lambda () (sleep-for 3) (list 12 42))
>               (lambda (result) (message "%s" result)))
>
> => after 3 sec it displays (12 42)
>
> However, since those packages simulate parallel/async jobs with another
> Emacs instance, you cannot execute code with side effects. Well, you
> can, but it won't have any effect in your current Emacs instance, only
> on the remote. You have to isolate the side effects and to put them in a
> function to be executed once the computation (free of side effect) is
> done (`finish-func' in `async-start' or `:post-exec' in
> `parallel-start').
>
> [1] https://github.com/daimrod/emacs-parallel.git
> [2] https://github.com/jwiegley/emacs-async.git






  reply	other threads:[~2013-07-13  6:38 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-08 13:25 bug#14820: 24.3; elisp manual: How to write good idle timer worker functions? Phil Sainty
2013-07-10  8:35 ` Stefan Monnier
2013-07-10 15:31   ` Phil Sainty
2013-07-11 13:39     ` Daimrod
2013-07-13  6:38       ` Phil Sainty [this message]
2013-07-11 22:52     ` Stefan Monnier
2022-01-26 17:41 ` Lars Ingebrigtsen
2022-02-23 20:15   ` Lars Ingebrigtsen

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=51E0F5F8.10206@orcon.net.nz \
    --to=psainty@orcon.net.nz \
    --cc=14820@debbugs.gnu.org \
    --cc=daimrod@gmail.com \
    /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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).