[Block Pointer] multithread help

Hi everybody, I was wondering if there is anybody familiar enough with Block Pointer that could give me a hand regarding multithread support. Once again the test file is at: https://svn.boost.org/svn/boost/sandbox/block_ptr/libs/smart_ptr/example/thr... The main class I am trying to protect with a mutex is block_header from: https://svn.boost.org/svn/boost/sandbox/block_ptr/boost/block_ptr.hpp Thanks, -Phil

On 5/12/2011 5:31 PM, Phil Bouchard wrote:
The main class I am trying to protect with a mutex is block_header from: https://svn.boost.org/svn/boost/sandbox/block_ptr/boost/block_ptr.hpp
block_header is the header of the set. A set is a group of memory blocks linked to the block_header. -Phil

On Thursday, May 12, 2011, Phil Bouchard wrote:
Hi everybody,
I was wondering if there is anybody familiar enough with Block Pointer that could give me a hand regarding multithread support. Once again the test file is at: https://svn.boost.org/svn/boost/sandbox/block_ptr/libs/smart_ptr/example/ thread_test.cpp
The main class I am trying to protect with a mutex is block_header from: https://svn.boost.org/svn/boost/sandbox/block_ptr/boost/block_ptr.hpp
It looks like you might be affected by the "static initialization order fiasco". Your test creates a global block_ptr, whose constructor seems to eventually use some class static boost::mutex. It's not clear that the constructors for the static boost::mutex will necessarily be run before the constructor of your global block_ptr.

On 5/13/2011 7:06 AM, Frank Mori Hess wrote:
It looks like you might be affected by the "static initialization order fiasco". Your test creates a global block_ptr, whose constructor seems to eventually use some class static boost::mutex. It's not clear that the constructors for the static boost::mutex will necessarily be run before the constructor of your global block_ptr.
That's a good point... but technically it is declared in the header, which is read first so it should be initialized first. -Phil

On 13/05/2011 19:10, Phil Bouchard wrote:
That's a good point... but technically it is declared in the header, which is read first so it should be initialized first.
That's not the rules of static initialization. If you want to enforce order, you have to use tricks to make variables dependent.

On 5/13/2011 10:33 AM, Mathias Gaunard wrote:
That's not the rules of static initialization. If you want to enforce order, you have to use tricks to make variables dependent.
Right... I could access an instance of the static objects within the constructor of block_ptr. Thanks! -Phil
participants (3)
-
Frank Mori Hess
-
Mathias Gaunard
-
Phil Bouchard