Boost logo

Boost :

From: William E. Kempf (williamkempf_at_[hidden])
Date: 2002-08-12 18:37:25


----- Original Message -----
From: "Peter Dimov" <pdimov_at_[hidden]>
> From: "William E. Kempf" <williamkempf_at_[hidden]>
> >
> > For an example I'll once again go back to the classic bounded buffer.
> Let's
> > imagine that I create a thread that's going to write out several items
to
> > this buffer... a lot more than the buffer can handle with out another
> thread
> > reading the values out.
>
> What is the return value of the writer thread, and who is supposed to
join()
> it?

I don't think that's relevant, but maybe I'm wrong.

> > Let's also imagine that I create yet another thread
> > to read this values out and sum them up. The result I'll return to the
> > caller when he join()s. This is very similar to an async call, but
> between
> > the call invocation and the returning of the result there's important
> > inter-thread interactions going on. With exception propagation I'm
> > concerned not only that the user may not call join() because he's not
> > interested in the result, only that the processing occurs, and thus
could
> > never receive the exception. No, I'm also concerned that if exception
> > propogation is the norm the niave user is lulled into thinking exception
> > handling is taken care of internally, and thus dead lock occurs when the
> > writing thread throws an exception while the reading thread is blocked
> > trying to read a value that will now never be added to the buffer.
>
> Why does the writing thread throw an exception? Why is exception
propagation
> in effect for the writer thread?

Who knows what caused the exception? Is that relevant? And I don't believe
I said that exception propogation was in effect for the writer thread...
though I see why you think that could make a difference. Maybe not the best
example because this can lead to the confusion you're having. I didn't
envision the writer thread as returning anything. But in that case you'll
say the user would likely be handling the exception correctly. OK, let's
say it's the reader that throws. Now when the writer fills up the buffer,
it to will deadlock.

Bill Kempf


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk