[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: async.el: A simple asynchronous framework for Emacs
From: |
John Wiegley |
Subject: |
Re: async.el: A simple asynchronous framework for Emacs |
Date: |
Tue, 19 Jun 2012 19:20:16 -0500 |
User-agent: |
Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.1 (darwin) |
Just a note, I've generalized async.el a bit further so that I can also have
async-start-process -- which uses a different process that Emacs, but keeps
the rest of the functionality the same.
So, asynchronous invocation of a lambda with callback is the same as before:
(async-start (lambda () ... in child process ...)
(lambda (ret) ... handle return value from lambda ...))
Now I can get the same sort of functionality with other processes too:
(async-start-process "cp" "/bin/cp"
(lambda (proc) ... use proc to get exit code ...)
"file1" "file2")
Further, as with `async-start', if the callback function is nil you'll get a
closure that you can inspect when you're ready. I've also added two new
functions for working with these futures:
(async-ready FUTURE) ; returns t if `async-get' would not block
(async-wait FUTURE) ; waits for FUTURE to become ready, returns nil
(async-get FUTURE)
Lastly, you can call `async-get' now even if you did provide a callback, it
will simply always return nil in that case (since the return value went to the
callback).
My motivation for `async-start-process' is that I want dired-async.el to use
native cp/mv/rm if all files are local (file-remote-p == nil). But I want to
keep the same infrastructure, i.e., the simple-to-specify callbacks for
manipulating the dired buffer once the operation is complete.
Updates are on GitHub.
John
- async.el: A simple asynchronous framework for Emacs, John Wiegley, 2012/06/18
- Re: async.el: A simple asynchronous framework for Emacs, Thien-Thi Nguyen, 2012/06/19
- Re: async.el: A simple asynchronous framework for Emacs, Stefan Monnier, 2012/06/19
- Re: async.el: A simple asynchronous framework for Emacs, John Wiegley, 2012/06/19
- Re: async.el: A simple asynchronous framework for Emacs, John Wiegley, 2012/06/20
- Re: async.el: A simple asynchronous framework for Emacs, SAKURAI Masashi, 2012/06/20
- Re: async.el: A simple asynchronous framework for Emacs, John Wiegley, 2012/06/20
- Re: async.el: A simple asynchronous framework for Emacs, John Wiegley, 2012/06/20
- Re: async.el: A simple asynchronous framework for Emacs, John Wiegley, 2012/06/20
- Re: async.el: A simple asynchronous framework for Emacs, SAKURAI Masashi, 2012/06/20
- Re: async.el: A simple asynchronous framework for Emacs, Thien-Thi Nguyen, 2012/06/20
- Re: async.el: A simple asynchronous framework for Emacs, John Wiegley, 2012/06/20
- Re: async.el: A simple asynchronous framework for Emacs, Thien-Thi Nguyen, 2012/06/21