16 Jan
2013
16 Jan
'13
1:49 a.m.
void CalledThousandsOfTimesPerSecondFromManyThreads(float f) { static const boost::format Formatter("%0.3f");
GetStream() << Formatter % f << GetSomeOtherContent(); }
I'm pretty sure boost::format is not thread safe
If you think about what it's doing, every time you call operator% it's inserting a formatted item into it's internal state. Think about what happens if you feed multiple elements via operator% and then call .str() - you get a std::string back - it has to store everything you've fed in internally so that you can access the formatted string later via .str()