Deallocate wxThreadSpecificInfo when wxThread ends.

Cleanup wxThreadSpecificInfo after wxThread::Entry returns to be more
memory efficient.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74834 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík
2013-09-18 16:03:25 +00:00
parent d2740de55e
commit 5278469615
9 changed files with 44 additions and 9 deletions

View File

@@ -52,6 +52,13 @@ public:
wxLocaleUntranslatedStrings untranslatedStrings;
#endif
#if wxUSE_THREADS
// Cleans up storage for the current thread. Should be called when a thread
// is being destroyed. If it's not called, the only bad thing that happens
// is that the memory is deallocated later, on process termination.
static void ThreadCleanUp();
#endif
private:
wxThreadSpecificInfo() : logger(NULL), loggingDisabled(false) {}
};

View File

@@ -614,6 +614,8 @@ protected:
// of this thread.
virtual void *Entry() = 0;
// use this to call the Entry() virtual method
void *CallEntry();
// Callbacks which may be overridden by the derived class to perform some
// specific actions when the thread is deleted or killed. By default they

View File

@@ -342,8 +342,16 @@ wxSemaError wxSemaphore::Post()
// ----------------------------------------------------------------------------
#include "wx/utils.h"
#include "wx/private/threadinfo.h"
#include "wx/scopeguard.h"
void wxThread::Sleep(unsigned long milliseconds)
{
wxMilliSleep(milliseconds);
}
void *wxThread::CallEntry()
{
wxON_BLOCK_EXIT0(wxThreadSpecificInfo::ThreadCleanUp);
return Entry();
}