TDPL message passing: OwnerFailed?

monarch_dodra monarchdodra at gmail.com
Tue Jan 22 07:01:58 PST 2013


On Tuesday, 22 January 2013 at 12:27:12 UTC, Martin Drasar wrote:
>
> Hi,
>
> wouldn't this help you?
>
> http://dlang.org/phobos/std_concurrency.html#.spawnLinked
>
> According to documentation: Executes the supplied function in a 
> new
> context represented by Tid. This new context is linked to the 
> calling
> context so that if either it or the calling context terminates a
> LinkTerminated message will be sent to the other, causing a
> LinkTerminated exception to be thrown on receive(). The owner
> relationship from spawn() is preserved as well, so if the link 
> between
> threads is broken, owner termination will still result in an
> OwnerTerminated exception to be thrown on receive().
>
> Martin

Thanks. I tried using it, but it is giving me problems in the 
sense that:
1) If the worker sends a message, and then dies, the 
"LinkTerminated" message is sometimes not caught by the owner.
2) When the worker needs to die its natural death, it is creating 
some LinkTerminated errors :/

Gotta keep tinkering.

On Tuesday, 22 January 2013 at 14:47:10 UTC, Ali Çehreli wrote:
> On 01/22/2013 04:26 AM, Martin Drasar wrote:
> > On 22.1.2013 11:08, monarch_dodra wrote:
> >> I was trying to do a simple program to test message passing.
>
> > wouldn't this help you?
> >
> > http://dlang.org/phobos/std_concurrency.html#.spawnLinked
>
> The following chapter may be helpful as well:
>
>   http://ddili.org/ders/d.en/concurrency.html
>
> Especially the following sections:
>
> - Exceptions during the execution of the worker
>
> - Detecting thread termination
>
> - Receiving exceptions as messages
>
> Ali

TY. Gonna read everything.


More information about the Digitalmars-d-learn mailing list