Untabified.
Quick hack to allow compilation, deleting threads is broken for now, though. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@26253 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -6,7 +6,7 @@
|
|||||||
// Created: 04/22/98
|
// Created: 04/22/98
|
||||||
// RCS-ID: $Id$
|
// RCS-ID: $Id$
|
||||||
// Copyright: (c) Stefan Neis (2003)
|
// Copyright: (c) Stefan Neis (2003)
|
||||||
//
|
//
|
||||||
// Licence: wxWindows licence
|
// Licence: wxWindows licence
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@@ -412,19 +412,19 @@ void wxThreadInternal::OS2ThreadStart(
|
|||||||
{
|
{
|
||||||
wxAppTraits *traits = wxTheApp ? wxTheApp->GetTraits() : NULL;
|
wxAppTraits *traits = wxTheApp ? wxTheApp->GetTraits() : NULL;
|
||||||
unsigned long ulHab;
|
unsigned long ulHab;
|
||||||
if (traits)
|
if (traits)
|
||||||
traits->InitializeGui(ulHab);
|
traits->InitializeGui(ulHab);
|
||||||
dwRet = (DWORD)pThread->Entry();
|
dwRet = (DWORD)pThread->Entry();
|
||||||
if (traits)
|
if (traits)
|
||||||
traits->TerminateGui(ulHab);
|
traits->TerminateGui(ulHab);
|
||||||
|
|
||||||
// enter m_critsect before changing the thread state
|
// enter m_critsect before changing the thread state
|
||||||
pThread->m_critsect.Enter();
|
pThread->m_critsect.Enter();
|
||||||
|
|
||||||
bWasCancelled = pThread->m_internal->GetState() == STATE_CANCELED;
|
bWasCancelled = pThread->m_internal->GetState() == STATE_CANCELED;
|
||||||
|
|
||||||
pThread->m_internal->SetState(STATE_EXITED);
|
pThread->m_internal->SetState(STATE_EXITED);
|
||||||
pThread->m_critsect.Leave();
|
pThread->m_critsect.Leave();
|
||||||
}
|
}
|
||||||
pThread->OnExit();
|
pThread->OnExit();
|
||||||
|
|
||||||
@@ -480,12 +480,12 @@ bool wxThreadInternal::Create(
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
int tid;
|
int tid;
|
||||||
|
|
||||||
if (!uStackSize)
|
if (!uStackSize)
|
||||||
uStackSize = 131072;
|
uStackSize = 131072;
|
||||||
pThread->m_critsect.Enter();
|
pThread->m_critsect.Enter();
|
||||||
tid = _beginthread(wxThreadInternal::OS2ThreadStart,
|
tid = _beginthread(wxThreadInternal::OS2ThreadStart,
|
||||||
NULL, uStackSize, pThread);
|
NULL, uStackSize, pThread);
|
||||||
if(tid == -1)
|
if(tid == -1)
|
||||||
{
|
{
|
||||||
wxLogSysError(_("Can't create thread"));
|
wxLogSysError(_("Can't create thread"));
|
||||||
@@ -662,9 +662,9 @@ wxThreadError wxThread::Resume()
|
|||||||
{
|
{
|
||||||
if (m_internal->GetState() == STATE_NEW)
|
if (m_internal->GetState() == STATE_NEW)
|
||||||
{
|
{
|
||||||
m_internal->SetState(STATE_RUNNING);
|
m_internal->SetState(STATE_RUNNING);
|
||||||
m_critsect.Leave();
|
m_critsect.Leave();
|
||||||
return wxTHREAD_NO_ERROR;
|
return wxTHREAD_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxCriticalSectionLocker lock((wxCriticalSection &)m_critsect);
|
wxCriticalSectionLocker lock((wxCriticalSection &)m_critsect);
|
||||||
@@ -734,7 +734,7 @@ wxThreadError wxThread::Delete(ExitCode *pRc)
|
|||||||
{
|
{
|
||||||
// set flag for wxIsWaitingForThread()
|
// set flag for wxIsWaitingForThread()
|
||||||
gs_bWaitingForThread = TRUE;
|
gs_bWaitingForThread = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ask the thread to terminate
|
// ask the thread to terminate
|
||||||
if ( shouldCancel )
|
if ( shouldCancel )
|
||||||
@@ -744,7 +744,7 @@ wxThreadError wxThread::Delete(ExitCode *pRc)
|
|||||||
m_internal->Cancel();
|
m_internal->Cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if wxUSE_GUI
|
#if 0
|
||||||
// we can't just wait for the thread to terminate because it might be
|
// we can't just wait for the thread to terminate because it might be
|
||||||
// calling some GUI functions and so it will never terminate before we
|
// calling some GUI functions and so it will never terminate before we
|
||||||
// process the Windows messages that result from these functions
|
// process the Windows messages that result from these functions
|
||||||
@@ -762,41 +762,41 @@ wxThreadError wxThread::Delete(ExitCode *pRc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
result = ::DosWaitThread(&hThread, DCWW_NOWAIT);
|
result = ::DosWaitThread(&hThread, DCWW_NOWAIT);
|
||||||
// FIXME: We ought to have a message processing loop here!!
|
// FIXME: We ought to have a message processing loop here!!
|
||||||
|
|
||||||
switch ( result )
|
switch ( result )
|
||||||
{
|
{
|
||||||
case ERROR_INTERRUPT:
|
case ERROR_INTERRUPT:
|
||||||
case ERROR_THREAD_NOT_TERMINATED:
|
case ERROR_THREAD_NOT_TERMINATED:
|
||||||
break;
|
break;
|
||||||
case ERROR_INVALID_THREADID:
|
case ERROR_INVALID_THREADID:
|
||||||
case NO_ERROR:
|
case NO_ERROR:
|
||||||
// thread we're waiting for just terminated
|
// thread we're waiting for just terminated
|
||||||
// or even does not exist any more.
|
// or even does not exist any more.
|
||||||
result = NO_ERROR;
|
result = NO_ERROR;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
wxFAIL_MSG(wxT("unexpected result of DosWaitThread"));
|
wxFAIL_MSG(wxT("unexpected result of DosWaitThread"));
|
||||||
}
|
}
|
||||||
if ( IsMain() )
|
if ( IsMain() )
|
||||||
{
|
{
|
||||||
// event processing - needed if we are the main thread
|
// event processing - needed if we are the main thread
|
||||||
// to give other threads a chance to do remaining GUI
|
// to give other threads a chance to do remaining GUI
|
||||||
// processing and terminate cleanly.
|
// processing and terminate cleanly.
|
||||||
wxTheApp->HandleSockets();
|
wxTheApp->HandleSockets();
|
||||||
if (wxTheApp->Pending())
|
if (wxTheApp->Pending())
|
||||||
if ( !wxTheApp->DoMessage() )
|
if ( !wxTheApp->DoMessage() )
|
||||||
{
|
{
|
||||||
// WM_QUIT received: kill the thread
|
// WM_QUIT received: kill the thread
|
||||||
Kill();
|
Kill();
|
||||||
|
|
||||||
return wxTHREAD_KILLED;
|
return wxTHREAD_KILLED;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
wxUsleep(10);
|
wxUsleep(10);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
wxUsleep(10);
|
wxUsleep(10);
|
||||||
} while ( result != NO_ERROR );
|
} while ( result != NO_ERROR );
|
||||||
#else // !wxUSE_GUI
|
#else // !wxUSE_GUI
|
||||||
// simply wait for the thread to terminate
|
// simply wait for the thread to terminate
|
||||||
|
Reference in New Issue
Block a user