[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [RFC] automatically retrying network connections
From: |
Michael Albinus |
Subject: |
Re: [RFC] automatically retrying network connections |
Date: |
Sun, 22 Jul 2018 18:44:46 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) |
Jimmy Yuen Ho Wong <address@hidden> writes:
> The latter, parellel requests, and then join the results when they all
> come back. I've come up with some bastardization of MapReduce now, but
> this would be a lot nicer if Emacs had something like
> https://github.com/chuntaro/emacs-promise built in, so I can combine
> it with a generator to emulate async/await semantics.
Emacs has threads. So you might do something like
(let (threads result)
;; Create a thread per request.
(setq threads
(mapcar
(lambda (request)
(make-thread
(lambda () <do your request>))))
<all-requests>)
;; Collect the results.
(thread-yield)
(dolist (thread threads result)
(setq result (cons (thread-join thread) result))))
Best regards, Michael.
Re: [RFC] automatically retrying network connections, Lars Ingebrigtsen, 2018/07/22