20 Aug
2009
20 Aug
'09
12:54 p.m.
As it seems to me - it must work ok. At least this (simplified variant): FILE* pConsole; boost::mutex consoleMutex; class logmsg { public: logmsg(const void* source, const char* msg) { boost::mutex::scoped_lock lock(consoleMutex); cout << msg << endl; } }; Note that: 1) there are no variable params. Probably problem was in that you haven't dealed with them (va_list, va_arg ...) 2) if you are creating logmsg in constructor of some global variable, then consoleMutex can be created later and you will actually work not with mutex, but with garbage in memory