TDPL, std.concurrency and OwnerFailed
Alexandr Druzhinin
drug2004 at bk.ru
Tue Sep 3 22:29:47 PDT 2013
04.09.2013 0:58, Ali Çehreli пишет:
> One way is, the child can send a special message (even the exception
> itself) when it terminates:
>
> // ... at the worker ...
> try {
> // ...
>
> } catch (shared(Exception) exc) {
> owner.send(exc);
> }},
>
This implies some protocol, at least simplest, but hand-made,
non-standard protocol - I'd like to avoid this if possible and use
standart ways
> Beware though: There has been problems with "disappearing workers" even
> with that code. The reason is, the code above does not catch Errors.
> However, if it did catch by Error (or, more generally by Throwable),
> then in theory, it shouldn't trust program state sufficiently to be able
> to send a message to the owner.
But if after catching Throwable and sending a message to the parent I
stop the worker - I won't be needed to trust a worker state, because it
won't be used more? Or again I need some protocol to avoid this case?
>
> > I know about spawnLinked, but I want to get known about child state when
> > sending, not receiving, because in the last case I don't know what of
> > linked child threads is terminated.
>
> I don't think it is a complete solution: Even if you think the child is
> healthy when you send the message, it may terminate right after
> receiving it.
You're absolutely right. So, ultimately I need some communication
protocol. It would be very nice if phobos has something like message
pattern in zeromq.
More information about the Digitalmars-d-learn
mailing list