[Top][All Lists]

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

Re: async 1.0

From: John Wiegley
Subject: Re: async 1.0
Date: Fri, 22 Jun 2012 16:39:23 -0500
User-agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.1 (darwin)

>>>>> Richard Stallman <address@hidden> writes:

> I didn't realize it could be so fast.  On my machine, emacs -Q -batch --eval
> "(+ 10 20)" takes about 1/4 second.

What kind of hardware are you using?  The Emacs that I'm running in off an SSD
with a lot of cache RAM available.  If I do it on my laptop, which also has an
SSD, I get the same times: 0.03713s.

I've also found another use for async.el: sandboxing.  The following allows me
execute a lambda synchronously, but without affecting the host Emacs

    (async-get (async-start FUNC))

I see this idiom being useful enough that I've reduced it to one function,
(async-sandbox FUNC).

Here's an example of using sandboxing to byte-compile a file, without letting
`eval-when-compile' forms affect the host environment:

    (let ((proc
            `(lambda ()
               (require 'bytecomp)
               ,(async-inject-variables "\\`load-path\\'")
               (let ((default-directory ,(file-name-directory file)))
                 (add-to-list 'load-path default-directory)
                   (load ,file))
                 ;; returns nil if there were any errors
                     (byte-compile-file ,file)
                   (load ,file)))))))

      (unless (condition-case err
                  (async-get proc)
                 (ignore (message "Error: %s" err))))
        (ignore (message "Recompiling %s...FAILED" file))))


reply via email to

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