emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Return value of finished threads


From: Michael Albinus
Subject: Re: Return value of finished threads
Date: Sat, 21 Jul 2018 11:39:17 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

Tom Tromey <address@hidden> writes:

Hi Tom,

> Michael> So I'm wondering if we could extend thread support by an
> Michael> indication of the thread result, when finished. One idea
> Michael> would be that `thread-join' returns with that value.
>
> This doesn't seem all that hard to implement.

Yep. The appended patch does it for me. Maybe you could check whether
I'm missing something?

> Also if the thread exited due to an exception of some kind, this could
> be propagated by thread-join as well.

Yeah, this would be a bonus. I've failed to implement it, so I let it to
somebody else. I don't need it first-hand.

> Michael> The documentation recommends the use of global variables,
> Michael> which would be inconvenient for many threads to supervise.
>
> Or you can use a queue of some kind and have each worker push its
> result there.

Yes, but you must indicate the worker threads where to push the
result. Imagine find-file would support threads for wildcard file names,
and somebody calls find-file this way twice, both running concurrently.
Every worker thread must know, whether to push the result into the
global variable associated with the first call or the second one. Still
overhead to implement; I'll prefer that thread-join returns the result.

> Tom

Best regards, Michael.

Attachment: txt_lfAQTBXUi.txt
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]