Closed thierryvolpiatto closed 7 years ago
@jwiegley Please verify I am not wrong in the return value of async-ready
and also about making async-wait
private.
Thanks.
async-wait
is intended to be a user-facing function that returns when async-get
would not block. Why did you want to make it private?
John Wiegley notifications@github.com writes:
async-wait is intended to be a user-facing function that returns when async-get would not block.
Ok, can you give some examples, perhaps in test file ?
Why did you want to make it private?
I had the impression it was only used internally, but was unsure about its usage, why I asked ;-).
Thanks.
-- Thierry
The example is simply this: If you call async-get
, it will block until the future provides a value, and then return that value. If you call async-wait
, it will also block until the future provides a value, but it does not return that value -- it leaves it unclaimed in the future. It provides a way to say, "I want to wait until the future is ready", without doing anything with that value.
John Wiegley notifications@github.com writes:
The example is simply this: If you call async-get, it will block until the future provides a value, and then return that value. If you call async-wait, it will also block until the future provides a value, but it does not return that value -- it leaves it unclaimed in the future. It provides a way to say, "I want to wait until the future is ready", without doing anything with that value.
Thanks for explanation.
However I think there is a bug here which makes an infloop in async-wait
if user touch a key, you can reproduce with following code:
(let ((proc (async-start
(lambda () (sit-for 3) (message "hello") ))))
(async-wait proc))
If you eval this code and touch nothing, it returns nil, ok, but if you hit a key before it finishes, it hangup forever.
A solution is using sleep-for
in async-wait
instead of sit-for
.
WDYT?
-- Thierry
Sure, that sounds good to me.
John Wiegley notifications@github.com writes:
Merged #72.
Thanks, rebased and merged in ELPA.
-- Thierry