LinkTerminated without linked thread?

monarch_dodra monarchdodra at gmail.com
Thu Jan 24 17:13:58 PST 2013


On Thursday, 24 January 2013 at 17:12:49 UTC, Sean Kelly wrote:
> On Jan 24, 2013, at 5:58 AM, "monarch_dodra" 
> <monarchdodra at gmail.com> wrote:
>
>> On Thursday, 24 January 2013 at 13:45:18 UTC, David Nadlinger 
>> wrote:
>>> On Thursday, 24 January 2013 at 10:57:26 UTC, Stephan wrote:
>>>> So my first question is: Where does the LinkTerminated 
>>>> Exception come from, when the only functions from 
>>>> std.concurrency that I use are "spawn" and "receiveOnly".
>>> 
>>> To track this down, what about looking at the std.concurrency 
>>> source and placing a breakpoint at the appropriate line in 
>>> MessageBox.get()?
>>> 
>>> David
>> 
>> Yeah, I've been playing with std.concurrency too lately, and 
>> getting random bugs. I'll try to formalize them into formal 
>> requests.
>> 
>> BTW: Question: Is "LinkTerminated" a priority message? I've 
>> been avoiding using SpawnLinked because I've been unable to 
>> effectively end my workers. Maybe I just suck though...
>
> It's a control message. These are messages generated 
> automatically by std.concurrency rather than sent by the user. 
> They live in the normal message queue and so are processed when 
> receive doesn't find a match earlier in the queue. The idea is 
> that if an owner sends a spawned thread a bunch of messages, 
> the spawned thread should have an opportunity to process those 
> messages before receiving an OwnerTerminated message.  Making 
> them priority messages would make designing predictable 
> algorithms difficult.

OK. TY.

I'll try to reproduce, but I'm 90% sure my reduced code was this:

//----
void worker(Tid owner)
{
   owner.send(1);
}

void main()
{
     spawnLinked(&worker, thisTid);
     receive(
         (int a){}
     );
}
//----
And it (50% of the time) terminated in a LinkTerminated exception 
being thrown.

Any quick thoughts? I'll investigate on my end depending on your 
explanation.


More information about the Digitalmars-d mailing list