lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lmi] Parallel blues


From: Vadim Zeitlin
Subject: Re: [lmi] Parallel blues
Date: Wed, 21 Jun 2017 01:28:09 +0200

On Tue, 20 Jun 2017 23:10:03 +0000 Greg Chicares <address@hidden> wrote:

[...]
GC> [...quoting just one part to highlight how easy it is...]
GC> 
GC> > +        std::thread t2([]()
GC> > +            {
GC> >              TestBirthdateLimitsExhaustively(oe_age_last_birthday);
GC> > +            });

 Just a word of warning: launching new threads is indeed as easy as it
could be in C++11, but you must not forget to call join() (or detach(), but
then you'd usually need to write more code for managing thread lifetime in
some more complicated way) before exiting the scope as otherwise thread
dtor will simply terminate the program. Personally I find this aspect of
std::thread design incredibly dangerous and, to loan a word from your
vocabulary in order to put it as mildly as possible, infelicitous. But we
must learn to live with it.

GC> I really do want to preserve the possibility of writing "idiosyncrasyT"
GC> in the "Comments" input field in order to see decimal_root()'s iterands.
GC> But I don't want to pay this much for it. I'll find a way that doesn't
GC> involve pointers.

 I'd be curious to see it. My favourite solution would be to use C++17
std::optional<> but we don't have it yet -- while we already don't want to
use boost::optional<> neither. And without it, passing a possibly null
pointer seems to be the most concise way to indicate the absence of the
stream. And we do need to be able to test for stream absence because
otherwise we wouldn't be able to get rid of value_cast<> calls overhead
which is probably more significant here than that of actually inserting
into the stream. And to avoid it, we simply must make the calls to
operator<<() conditional, hence we need something to test for.

 Good luck,
VZ


reply via email to

[Prev in Thread] Current Thread [Next in Thread]