Allow object local MessageBox's in concurreny
monarch_dodra
monarchdodra at gmail.com
Tue Feb 12 07:56:06 PST 2013
On Tuesday, 12 February 2013 at 15:26:18 UTC, FG wrote:
> On 2013-02-12 14:47, monarch_dodra wrote:
>> Does anybody have any preliminary feedback, objections,
>> remarks?
>
> You will encounter a possible problem on main thread
> termination.
> Normally it's done automatically in static ~this(): a linkDead
> message is sent to all spawned threads listed in "links" and
> then close() is called on the mbox. Those linkDead messages
> have thisTid as sender and that's a problem, because with
> custom mailbox thisTid != ownerTid, so the child won't treat
> that message as OwnerTerminated. It's caused by "links" being
> global and populated by spawn(). And if you make your own
> spawn, that doesn't touch links, the child won't be informed
> about parent's sudden death. How do you work around that?
That's a good point. For starters, I'd call "myTid.spawn(...)" so
as to set the correct "owner" for the spwaned thread. This is
especially relevant what with the new global "ownerTid" that
should get introduced in 2.062
The real question though (IMO) is rather: Why isn't "links" a
member field of the MessageBox itself?
By placing it inside MessageBox, it changes *nothing* for "static
~this()".
As for user generated MessageBoxes, the message will be sent when
the MessageBox itself is finalized.
The only problem with this approach is that there might be a
delay between when the last reference to the MessageBox is
destroyed, and the finalizer actually kicks in. Not entirely sure
this is a huge problem though, since we *are* dealing with
threads after all.
Also, just the same way a File can be closed either explicitly or
implicitly, we can give Tid a "die" member to explicitly notify
an incoming death.
I'll put more thought into it anyways.
More information about the Digitalmars-d
mailing list