Problem with LOG macros in multi threaded NT environment
McWilliams, Gary
gmcwilliams____cccnetsys.com
Wed May 24 13:04:37 CEST 2000
I have changed the LOG macros in log.h as follows:
#define LOG_BEGIN(x) DefaultLog::log_entry = new LogEntry(x)
#define LOG(x) *DefaultLog::log_entry += x
#define LOG_END *DefaultLog::log += DefaultLog::log_entry; delete
DefaultLog::log_entry
from
#define LOG_BEGIN(x) { LogEntry* log_entry = new LogEntry(x)
#define LOG(x) (*log_entry) += x
#define LOG_END *DefaultLog::log += log_entry; delete log_entry; }
I have a problem in that the DefaultLog::log_entry pointer is class static
(thus shared), and if we have multiple threads logging, then it can get very
confused.
My solution is to just have each logger create a local Log_Entry on the heap
and log that, then tidy up afterwards.
--
Gary McWilliams
Principal Engineer
CCC Network Systems Ltd, R&D facility Belfast
http://www.cccnetsys.com
More information about the AGENTPP
mailing list