make wxThread::OnExit private and not public (change tested on wxMSW and wxGTK)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@56984 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -271,7 +271,7 @@ private:
|
|||||||
|
|
||||||
#if wxCRITSECT_IS_MUTEX
|
#if wxCRITSECT_IS_MUTEX
|
||||||
// implement wxCriticalSection using mutexes
|
// implement wxCriticalSection using mutexes
|
||||||
inline wxCriticalSection::wxCriticalSection( wxCriticalSectionType critSecType )
|
inline wxCriticalSection::wxCriticalSection( wxCriticalSectionType critSecType )
|
||||||
: m_mutex( critSecType == wxCRITSEC_DEFAULT ? wxMUTEX_RECURSIVE : wxMUTEX_DEFAULT ) { }
|
: m_mutex( critSecType == wxCRITSEC_DEFAULT ? wxMUTEX_RECURSIVE : wxMUTEX_DEFAULT ) { }
|
||||||
inline wxCriticalSection::~wxCriticalSection() { }
|
inline wxCriticalSection::~wxCriticalSection() { }
|
||||||
|
|
||||||
@@ -558,11 +558,6 @@ public:
|
|||||||
wxThreadKind GetKind() const
|
wxThreadKind GetKind() const
|
||||||
{ return m_isDetached ? wxTHREAD_DETACHED : wxTHREAD_JOINABLE; }
|
{ return m_isDetached ? wxTHREAD_DETACHED : wxTHREAD_JOINABLE; }
|
||||||
|
|
||||||
// called when the thread exits - in the context of this thread
|
|
||||||
//
|
|
||||||
// NB: this function will not be called if the thread is Kill()ed
|
|
||||||
virtual void OnExit() { }
|
|
||||||
|
|
||||||
// Returns true if the thread was asked to terminate: this function should
|
// Returns true if the thread was asked to terminate: this function should
|
||||||
// be called by the thread from time to time, otherwise the main thread
|
// be called by the thread from time to time, otherwise the main thread
|
||||||
// will be left forever in Delete()!
|
// will be left forever in Delete()!
|
||||||
@@ -585,6 +580,11 @@ private:
|
|||||||
wxThread(const wxThread&);
|
wxThread(const wxThread&);
|
||||||
wxThread& operator=(const wxThread&);
|
wxThread& operator=(const wxThread&);
|
||||||
|
|
||||||
|
// called when the thread exits - in the context of this thread
|
||||||
|
//
|
||||||
|
// NB: this function will not be called if the thread is Kill()ed
|
||||||
|
virtual void OnExit() { }
|
||||||
|
|
||||||
friend class wxThreadInternal;
|
friend class wxThreadInternal;
|
||||||
|
|
||||||
// the (platform-dependent) thread class implementation
|
// the (platform-dependent) thread class implementation
|
||||||
@@ -639,14 +639,14 @@ private:
|
|||||||
// sets it to NULL, then the thread object still
|
// sets it to NULL, then the thread object still
|
||||||
// exists and can be killed
|
// exists and can be killed
|
||||||
wxCriticalSectionLocker locker(m_critSection);
|
wxCriticalSectionLocker locker(m_critSection);
|
||||||
|
|
||||||
if ( m_thread )
|
if ( m_thread )
|
||||||
{
|
{
|
||||||
m_thread->Kill();
|
m_thread->Kill();
|
||||||
|
|
||||||
if ( m_kind == wxTHREAD_JOINABLE )
|
if ( m_kind == wxTHREAD_JOINABLE )
|
||||||
delete m_thread;
|
delete m_thread;
|
||||||
|
|
||||||
m_thread = NULL;
|
m_thread = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -678,9 +678,9 @@ public:
|
|||||||
wxThread *GetThread() const
|
wxThread *GetThread() const
|
||||||
{
|
{
|
||||||
wxCriticalSectionLocker locker((wxCriticalSection&)m_critSection);
|
wxCriticalSectionLocker locker((wxCriticalSection&)m_critSection);
|
||||||
|
|
||||||
wxThread* thread = m_thread;
|
wxThread* thread = m_thread;
|
||||||
|
|
||||||
return thread;
|
return thread;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -688,7 +688,7 @@ protected:
|
|||||||
wxThread *m_thread;
|
wxThread *m_thread;
|
||||||
wxThreadKind m_kind;
|
wxThreadKind m_kind;
|
||||||
wxCriticalSection m_critSection; // To guard the m_thread variable
|
wxCriticalSection m_critSection; // To guard the m_thread variable
|
||||||
|
|
||||||
friend class wxThreadHelperThread;
|
friend class wxThreadHelperThread;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -696,16 +696,16 @@ protected:
|
|||||||
inline void *wxThreadHelperThread::Entry()
|
inline void *wxThreadHelperThread::Entry()
|
||||||
{
|
{
|
||||||
void * const result = m_owner.Entry();
|
void * const result = m_owner.Entry();
|
||||||
|
|
||||||
wxCriticalSectionLocker locker(m_owner.m_critSection);
|
wxCriticalSectionLocker locker(m_owner.m_critSection);
|
||||||
|
|
||||||
// Detached thread will be deleted after returning, so make sure
|
// Detached thread will be deleted after returning, so make sure
|
||||||
// wxThreadHelper::GetThread will not return an invalid pointer.
|
// wxThreadHelper::GetThread will not return an invalid pointer.
|
||||||
// And that wxThreadHelper::KillThread will not try to kill
|
// And that wxThreadHelper::KillThread will not try to kill
|
||||||
// an already deleted thread
|
// an already deleted thread
|
||||||
if ( m_owner.m_kind == wxTHREAD_DETACHED )
|
if ( m_owner.m_kind == wxTHREAD_DETACHED )
|
||||||
m_owner.m_thread = NULL;
|
m_owner.m_thread = NULL;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1058,17 +1058,6 @@ public:
|
|||||||
*/
|
*/
|
||||||
wxThreadError Kill();
|
wxThreadError Kill();
|
||||||
|
|
||||||
/**
|
|
||||||
Called when the thread exits.
|
|
||||||
|
|
||||||
This function is called in the context of the thread associated with the
|
|
||||||
wxThread object, not in the context of the main thread.
|
|
||||||
This function will not be called if the thread was @ref Kill() killed.
|
|
||||||
|
|
||||||
This function should never be called directly.
|
|
||||||
*/
|
|
||||||
virtual void OnExit();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Suspends the thread.
|
Suspends the thread.
|
||||||
|
|
||||||
@@ -1227,6 +1216,19 @@ protected:
|
|||||||
OnExit() will be called just before exiting.
|
OnExit() will be called just before exiting.
|
||||||
*/
|
*/
|
||||||
void Exit(ExitCode exitcode = 0);
|
void Exit(ExitCode exitcode = 0);
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
/**
|
||||||
|
Called when the thread exits.
|
||||||
|
|
||||||
|
This function is called in the context of the thread associated with the
|
||||||
|
wxThread object, not in the context of the main thread.
|
||||||
|
This function will not be called if the thread was @ref Kill() killed.
|
||||||
|
|
||||||
|
This function should never be called directly.
|
||||||
|
*/
|
||||||
|
virtual void OnExit();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user