An Issue I Wish To Raise Awareness On
via Digitalmars-d
digitalmars-d at puremagic.com
Thu Jul 20 03:37:47 PDT 2017
On Thursday, 20 July 2017 at 10:19:30 UTC, Kagamin wrote:
> On Thursday, 20 July 2017 at 07:40:35 UTC, Dominikus Dittes
> Scherkl wrote:
>> On Wednesday, 19 July 2017 at 22:35:43 UTC, Jonathan M Davis
>> wrote:
>>> The issue isn't the object being destroyed. It's what it
>>> refers to via its member variables. For instance, what if an
>>> object were to remove itself from a shared list when it's
>>> destroyed (e.g. because it's an observer in the observer
>>> pattern). The object has a reference to the list, but it
>>> doesn't own it.
>> So, even a thread-local object that has references to a shared
>> list
>> has to handle those as shared, even in its non-shared
>> destructor.
>> I can't follow your argument.
>
> Thread local object can't be contained in a shared list, the
> list is referred as unqualified, and thread local object will
> be contained in a thread local list, and shared object will be
> contained in a shared list because of transitivity of the
> shared qualifier.
It's the other way around:
ThreadLocal tl;
struct ThreadLocal
{
shared(ListNode*)* listHead;
shared(ListNode)* listNode;
~this()
{
listHead.removeNodeFromList(listNode);
}
}
More information about the Digitalmars-d
mailing list