Boost logo

Boost :

From: Alexander Terekhov (terekhov_at_[hidden])
Date: 2002-08-24 14:00:19


Peter Dimov wrote:
[...]
> R * timedjoin(time); // 0 (or nonportable special value) on timeout

That's basically what thread::timedout< R >( R* timed_join_result ),
thread::canceled< R >( R* any_join_result ) and thread::busy< R >( R*
try_join_result ) is supposed to test. Well, I'd probably "maintain"
all these states [plus "joined successfully"... and maybe even thread::
joined< T >( R* any_join_result )] in some "implementation-defined"
way -- nonportable special values, whatever.

I guess, another thing to consider is whether to use raw pointer or
some proxy/"wrapper". Proxy could then even addref/unref thread object
containing the return_value... (auto_ptr-like move-on-copy semantics,
of course ;-) ) but I somewhat dislike associated overhead of locking
on unref() (extra "ref()" on proxy creation inside join is basically
"free", I think).

> R timedjoin(time) throw (timed_out);

Don't like this one. I just hate writing not-for-true-recovery-catch-
handlers. ;-)

> bool timedjoin(time); // false on timeout, need join() to extract return
> value

This one is basically "doing it twice" -- with doubled overhead. (locking,
etc.) Don't like this one either. And it still doesn't address the problem
of canceled-thread-no-result (e.g. on the "second" join in this case, for
example). Making "not-canceled" being a precondition for join isn't really
attractive to me either... apart from that's-just-yet-another-occasion-to-
meet-my-lovely-std::logic_error! ;-) Well, alternatively, we might throw
something along the lines of "joined_thread_canceled" exception. ;-) ;-)

regards,
alexander.


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