[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [RFC] automatically retrying network connections
From: |
Jimmy Yuen Ho Wong |
Subject: |
Re: [RFC] automatically retrying network connections |
Date: |
Mon, 23 Jul 2018 00:24:19 +0100 |
On Sun, Jul 22, 2018 at 5:44 PM, Michael Albinus <address@hidden> wrote:
> 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.
Every `thread-join` blocks, isn't it basically the same as a generator?
If nobody objects, I'm just going to use a generator for now, and see
if I can get the emacs-promise author to donate it to the core.
Re: [RFC] automatically retrying network connections, Lars Ingebrigtsen, 2018/07/22
Re: [RFC] automatically retrying network connections, Andy Moreton, 2018/07/22