[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master bd11e73 1/2: Fix and clarify async-ready, async-get and as
From: |
Thierry Volpiatto |
Subject: |
[elpa] master bd11e73 1/2: Fix and clarify async-ready, async-get and async-wait. |
Date: |
Sun, 19 Feb 2017 13:15:43 -0500 (EST) |
branch: master
commit bd11e73689b7fabb82ea8223762039ced33c6199
Author: Thierry Volpiatto <address@hidden>
Commit: Thierry Volpiatto <address@hidden>
Fix and clarify async-ready, async-get and async-wait.
* async.el (async-ready): Ensure proc buffer is alive
and return t if buffer is not alive. Fix docstring.
(async-get): Ensure proc buffer is alive. Fix docstring.
(async-wait): Using sleep-for instead of sit-for prevent infloop.
(async-start): Docstring only.
---
async.el | 24 ++++++++++++++++--------
1 file changed, 16 insertions(+), 8 deletions(-)
diff --git a/async.el b/async.el
index 0bb45fa..30476e2 100644
--- a/async.el
+++ b/async.el
@@ -169,24 +169,32 @@ as follows:
(prin1 (list 'async-signal err)))))))
(defun async-ready (future)
- "Query a FUTURE to see if the ready is ready -- i.e., if no blocking
+ "Query a FUTURE to see if it is ready.
+
+I.e., if no blocking
would result from a call to `async-get' on that FUTURE."
(and (memq (process-status future) '(exit signal))
- (with-current-buffer (process-buffer future)
- async-callback-value-set)))
+ (let ((buf (process-buffer future)))
+ (if (buffer-live-p buf)
+ (with-current-buffer buf
+ async-callback-value-set)
+ t))))
(defun async-wait (future)
"Wait for FUTURE to become ready."
(while (not (async-ready future))
- (sit-for 0.05)))
+ (sleep-for 0.05)))
(defun async-get (future)
- "Get the value from an asynchronously function when it is ready.
+ "Get the value from process FUTURE when it is ready.
FUTURE is returned by `async-start' or `async-start-process' when
its FINISH-FUNC is nil."
- (async-wait future)
- (with-current-buffer (process-buffer future)
- (async-handle-result #'identity async-callback-value (current-buffer))))
+ (and future (async-wait future))
+ (let ((buf (process-buffer future)))
+ (when (buffer-live-p buf)
+ (with-current-buffer buf
+ (async-handle-result
+ #'identity async-callback-value (current-buffer))))))
(defun async-message-p (value)
"Return true of VALUE is an async.el message packet."
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [elpa] master bd11e73 1/2: Fix and clarify async-ready, async-get and async-wait.,
Thierry Volpiatto <=