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: Tom Tromey
Subject: Re: Return value of finished threads
Date: Sat, 21 Jul 2018 12:16:26 -0600
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1.50 (gnu/linux)

>> I was wondering which semantics would be preferred here.
>> Having each thread-join return the same result doesn't seem so bad either.

Michael> I have no strong preference. But returning the result only once has the
Michael> advantage, that you could remove all thread data from a dead thread,
Michael> once the result has been shown.

I think it's somewhat better to keep the value.  This avoids races or
the need for an extra rendezvous of some kind if there are multiple
joiners.

Keeping the value does mean that it is not GC'd.  However, normally the
idea would be to accomplish this by forgetting the dead thread in the
first place; which I would imagine is the most normal course of action.
So I tend to think this isn't a major concern.

Michael> How long do we keep the results of dead threads, for which no
Michael> thread-join happens? Do we need a Lisp cleanup function, which purges
Michael> all dead threads results? Or does this the GC, when no Lisp object 
holds
Michael> the dead thread any longer?

Tom> I didn't look deeply but I think instead of mark_threads, alloc.c would
Tom> need to mark any thread it runs across; and then mark_one_thread could
Tom> handle exited threads specially.

Michael> This goes into the darkness I'm not familiar with.

Good news -- it turns out I was mistaken about this.

The ordinary Lisp_Object fields of a thread are marked by mark_object,
because it is a pseudovector.  The other fields are what are marked
specially by mark_threads -- and these only need to be marked for live
threads.

I think a documentation update and a NEWS entry would be required.

thanks,
Tom



reply via email to

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