Made wxLogXXX() functions thread-safe.

They can now be called from any thread and will buffer the messages until the
current log target is flushed from the main thread. This makes earlier code to
do the same thing specifically for wxLogWindow unnecessary and also allows to
use wxLogMessage() in the thread sample instead of using manual logging there.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61416 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2009-07-12 17:02:30 +00:00
parent dbe0872fc8
commit 232addd1cd
6 changed files with 228 additions and 136 deletions

View File

@@ -289,6 +289,26 @@ private:
#define wxLOG_KEY_TRACE_MASK "wx.trace_mask"
// ----------------------------------------------------------------------------
// log record: a unit of log output
// ----------------------------------------------------------------------------
struct wxLogRecord
{
wxLogRecord(wxLogLevel level_,
const wxString& msg_,
const wxLogRecordInfo& info_)
: level(level_),
msg(msg_),
info(info_)
{
}
wxLogLevel level;
wxString msg;
wxLogRecordInfo info;
};
// ----------------------------------------------------------------------------
// derive from this class to redirect (or suppress, or ...) log messages
// normally, only a single instance of this class exists but it's not enforced
@@ -564,6 +584,13 @@ private:
// caller had already locked GetPreviousLogCS()
unsigned LogLastRepeatIfNeededUnlocked();
// called from OnLog() if it's called from the main thread and from Flush()
// when it plays back the buffered messages logged from the other threads
void OnLogInMainThread(wxLogLevel level,
const wxString& msg,
const wxLogRecordInfo& info);
// static variables
// ----------------