From: Ion Gaztañaga (ion_g_m_at_[hidden])
Date: 2005-04-24 13:58:47
Peter Dimov wrote:
>>Use aligned_storage<> and placement new.
Sorry, I didn't know what aligned_storage was for, boost is really huge.
I've seen it uses a union using alignment information from other boost
tools. Doing an placement new invalidates automatic destructor, so it sounds
to me like the famous ugly pimpl hack to avoid dynamic memory and header
dependences, based on max_align. Anyway, it is true that dynamic memory is
the best way to make thread lifetime independent from boost::thread object's
lifetime, so maybe in those special systems, a singleton memory pool should
be used for this, if "new" function is not available. What I don't know if
that singleton lifetime can lead to problems because I don't know if threads
must exit before static object destructors are called, but this is another
topic. I think embedded C++ should be taken in care because C++ is used a
lot in this area (for example, eCos embedded OS is written in C++ with a C
wrapper API). The C++ phylosophy ("you don't pay for what you don't use") is
very nice in these systems, if you know what is happening behind the scenes
with C++ (inheritance, constructor/destructors, etc...).
It would be nice to have some brainstorming regarding boost threads if it
is possible. I don't know if C++0x wants only to include basic functionality
in threads but I think developers are waiting for some more complex
utilities, like thread pools.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk