Revision 8432e54...
Go back to digest for 3rd February 2013Bug Fixes in Development Tools
Fix the memory pool thread local data access for good.
The issue was quite apparent yet I wonder how I could have been so
lucky as to never encounter it until today...
Thing is, we create the parse session (and thus also the memory pool)
in the constructor of the CPPParseJob which is still in e.g. the main
thread. Only later inside ::run() are we actually in the background
thread - and there we access the thread local data from inside
MemoryPool::allocateBlock.
Now we used to initialize the thread local data in the MemoryPool
but that is of course a different thread than what we encounter in
MemoryPool::allocateBlock later on.
The fix is quite simple and elegant, and actually makes the memory
pool even faster. We now initialize the thread local cache only
upon first destruction of a memory pool. Any access in allocateBlock
before could not find free blocks anyways.
Furthermore we now only allocate the first block once we actually
need it (i.e. upon first call to ::allocate()).
File Changes
- languages/cpp/parser/memorypool.cpp