Motif corrections in
wxDC (match wxWin 2.0 drawing stuff) on idle handling -> speed-up threads work now modules work now (also in release mode...) wxMotif compiles with configure again git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1282 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -38,7 +38,7 @@ GUISUFFIX = _stubs
|
|||||||
# Misc options
|
# Misc options
|
||||||
OPTIONS = -D__WXDEBUG__
|
OPTIONS = -D__WXDEBUG__
|
||||||
COPTIONS =
|
COPTIONS =
|
||||||
DEBUGFLAGS = -ggdb
|
DEBUGFLAGS =
|
||||||
INCLUDE =
|
INCLUDE =
|
||||||
WARN = -Wall -Wno-unused # -w
|
WARN = -Wall -Wno-unused # -w
|
||||||
CWARN = -Wall -Wno-unused # -w
|
CWARN = -Wall -Wno-unused # -w
|
||||||
|
@@ -105,7 +105,6 @@ LIB_CPP_SRC=\
|
|||||||
motif/metafile.cpp \
|
motif/metafile.cpp \
|
||||||
motif/minifram.cpp \
|
motif/minifram.cpp \
|
||||||
motif/msgdlg.cpp \
|
motif/msgdlg.cpp \
|
||||||
motif/notebook.cpp \
|
|
||||||
motif/palette.cpp \
|
motif/palette.cpp \
|
||||||
motif/pen.cpp \
|
motif/pen.cpp \
|
||||||
motif/print.cpp \
|
motif/print.cpp \
|
||||||
@@ -138,6 +137,7 @@ LIB_CPP_SRC=\
|
|||||||
generic/listctrl.cpp \
|
generic/listctrl.cpp \
|
||||||
generic/laywin.cpp \
|
generic/laywin.cpp \
|
||||||
generic/msgdlgg.cpp \
|
generic/msgdlgg.cpp \
|
||||||
|
generic/notebook.cpp \
|
||||||
generic/panelg.cpp \
|
generic/panelg.cpp \
|
||||||
generic/printps.cpp \
|
generic/printps.cpp \
|
||||||
generic/prntdlgg.cpp \
|
generic/prntdlgg.cpp \
|
||||||
|
@@ -28,6 +28,7 @@
|
|||||||
#include "wx/log.h"
|
#include "wx/log.h"
|
||||||
#include "wx/module.h"
|
#include "wx/module.h"
|
||||||
#include "wx/memory.h"
|
#include "wx/memory.h"
|
||||||
|
#include "wx/thread.h"
|
||||||
|
|
||||||
#if wxUSE_WX_RESOURCES
|
#if wxUSE_WX_RESOURCES
|
||||||
#include "wx/resource.h"
|
#include "wx/resource.h"
|
||||||
@@ -93,7 +94,7 @@ bool wxApp::Initialize()
|
|||||||
wxWidgetHashTable = new wxHashTable(wxKEY_INTEGER);
|
wxWidgetHashTable = new wxHashTable(wxKEY_INTEGER);
|
||||||
|
|
||||||
wxModule::RegisterModules();
|
wxModule::RegisterModules();
|
||||||
wxASSERT( wxModule::InitializeModules() == TRUE );
|
if (!wxModule::InitializeModules()) return FALSE;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@@ -293,7 +294,17 @@ int wxApp::MainLoop()
|
|||||||
XtAppNextEvent( (XtAppContext) wxTheApp->GetAppContext(), &event);
|
XtAppNextEvent( (XtAppContext) wxTheApp->GetAppContext(), &event);
|
||||||
|
|
||||||
ProcessXEvent((WXEvent*) & event);
|
ProcessXEvent((WXEvent*) & event);
|
||||||
ProcessIdle();
|
|
||||||
|
if (XtAppPending( (XtAppContext) wxTheApp->GetAppContext() ) == 0)
|
||||||
|
{
|
||||||
|
if (!ProcessIdle())
|
||||||
|
{
|
||||||
|
wxMutexGuiLeave();
|
||||||
|
usleep(20);
|
||||||
|
wxMutexGuiEnter();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@@ -57,8 +57,10 @@ static Pixmap bdiag, cdiag, fdiag, cross, horiz, verti;
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
#define RAD2DEG 57.2957795131
|
#define RAD2DEG 57.2957795131
|
||||||
|
|
||||||
// Fudge factor. Obsolete?
|
// Fudge factor. Obsolete?
|
||||||
#define WX_GC_CF 0
|
// No. Robert Roebling
|
||||||
|
#define WX_GC_CF 1
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// wxWindowDC
|
// wxWindowDC
|
||||||
@@ -1515,7 +1517,7 @@ void wxWindowDC::SetPen( const wxPen &pen )
|
|||||||
break;
|
break;
|
||||||
case wxCAP_ROUND:
|
case wxCAP_ROUND:
|
||||||
default:
|
default:
|
||||||
cap = CapRound;
|
cap = (scaled_width <= 1) ? CapNotLast : CapRound;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// Name: thread.cpp
|
// Name: thread.cpp
|
||||||
// Purpose: wxThread Implementation. For Unix ports, see e.g. src/gtk
|
// Purpose: wxThread Implementation for Posix threads
|
||||||
// Author: Original from Wolfram Gloger/Guilhem Lavaux
|
// Author: Original from Wolfram Gloger/Guilhem Lavaux
|
||||||
// Modified by:
|
// Modified by: Robert Roebling
|
||||||
// Created: 04/22/98
|
// Created: 04/22/98
|
||||||
// RCS-ID: $Id$
|
// RCS-ID: $Id$
|
||||||
// Copyright: (c) Wolfram Gloger (1996, 1997); Guilhem Lavaux (1998)
|
// Copyright: (c) Wolfram Gloger (1996, 1997); Guilhem Lavaux (1998)
|
||||||
@@ -13,56 +13,127 @@
|
|||||||
#pragma implementation "thread.h"
|
#pragma implementation "thread.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <pthread.h>
|
||||||
|
#include <errno.h>
|
||||||
#include "wx/module.h"
|
#include "wx/module.h"
|
||||||
#include "wx/thread.h"
|
#include "wx/thread.h"
|
||||||
#include "wx/utils.h"
|
#include "wx/utils.h"
|
||||||
|
#include "wx/log.h"
|
||||||
|
|
||||||
enum thread_state {
|
#include <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
// for select()
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#ifdef __sgi
|
||||||
|
#include <bstring.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
// constants
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
|
enum thread_state
|
||||||
|
{
|
||||||
STATE_IDLE = 0,
|
STATE_IDLE = 0,
|
||||||
STATE_RUNNING,
|
STATE_RUNNING,
|
||||||
|
STATE_PAUSING,
|
||||||
|
STATE_PAUSED,
|
||||||
STATE_CANCELED,
|
STATE_CANCELED,
|
||||||
STATE_EXITED
|
STATE_EXITED
|
||||||
};
|
};
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
//--------------------------------------------------------------------
|
||||||
// Static variables
|
// global data
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
wxMutex *wxMainMutex; // controls access to all GUI functions
|
static pthread_t p_mainid;
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
wxMutex *wxMainMutex = (wxMutex*) NULL; /* controls access to all GUI functions */
|
||||||
// Windows implementation
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
class wxMutexInternal {
|
/* TODO for Xt */
|
||||||
|
|
||||||
|
static int p_thrd_pipe[2] = { -1, -1 };
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------------
|
||||||
|
// global functions
|
||||||
|
//-------------------------------------------------------------------------
|
||||||
|
|
||||||
|
static void wxThreadGuiInit()
|
||||||
|
{
|
||||||
|
/* TODO for Xt */
|
||||||
|
}
|
||||||
|
|
||||||
|
static void wxThreadGuiExit()
|
||||||
|
{
|
||||||
|
/* TODO for Xt */
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxMutexGuiEnter()
|
||||||
|
{
|
||||||
|
if (wxMainMutex)
|
||||||
|
wxMainMutex->Lock();
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxMutexGuiLeave()
|
||||||
|
{
|
||||||
|
if (wxMainMutex)
|
||||||
|
wxMainMutex->Unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
// wxMutex (Posix implementation)
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
|
class wxMutexInternal
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
// TODO: internal mutex handle
|
pthread_mutex_t p_mutex;
|
||||||
};
|
};
|
||||||
|
|
||||||
wxMutex::wxMutex()
|
wxMutex::wxMutex()
|
||||||
{
|
{
|
||||||
p_internal = new wxMutexInternal;
|
p_internal = new wxMutexInternal;
|
||||||
// TODO: create internal mutext handle
|
pthread_mutex_init(&(p_internal->p_mutex), NULL);
|
||||||
m_locked = 0;
|
m_locked = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxMutex::~wxMutex()
|
wxMutex::~wxMutex()
|
||||||
{
|
{
|
||||||
if (m_locked > 0)
|
if (m_locked > 0)
|
||||||
wxDebugMsg("wxMutex warning: freeing a locked mutex (%d locks)\n", m_locked);
|
wxLogDebug( "wxMutex warning: freeing a locked mutex (%d locks)\n", m_locked );
|
||||||
// TODO: free internal mutext handle
|
|
||||||
|
pthread_mutex_destroy(&(p_internal->p_mutex));
|
||||||
|
delete p_internal;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxMutexError wxMutex::Lock()
|
wxMutexError wxMutex::Lock()
|
||||||
{
|
{
|
||||||
// TODO
|
int err;
|
||||||
|
|
||||||
|
err = pthread_mutex_lock(&(p_internal->p_mutex));
|
||||||
|
if (err == EDEADLK)
|
||||||
|
return wxMUTEX_DEAD_LOCK;
|
||||||
|
|
||||||
m_locked++;
|
m_locked++;
|
||||||
return wxMUTEX_NO_ERROR;
|
return wxMUTEX_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxMutexError wxMutex::TryLock()
|
wxMutexError wxMutex::TryLock()
|
||||||
{
|
{
|
||||||
// TODO
|
int err;
|
||||||
|
|
||||||
|
if (m_locked)
|
||||||
|
return wxMUTEX_BUSY;
|
||||||
|
|
||||||
|
err = pthread_mutex_trylock(&(p_internal->p_mutex));
|
||||||
|
switch (err)
|
||||||
|
{
|
||||||
|
case EBUSY: return wxMUTEX_BUSY;
|
||||||
|
}
|
||||||
m_locked++;
|
m_locked++;
|
||||||
return wxMUTEX_NO_ERROR;
|
return wxMUTEX_NO_ERROR;
|
||||||
}
|
}
|
||||||
@@ -71,159 +142,254 @@ wxMutexError wxMutex::Unlock()
|
|||||||
{
|
{
|
||||||
if (m_locked > 0)
|
if (m_locked > 0)
|
||||||
m_locked--;
|
m_locked--;
|
||||||
|
else
|
||||||
// TODO
|
return wxMUTEX_UNLOCKED;
|
||||||
|
|
||||||
|
pthread_mutex_unlock(&(p_internal->p_mutex));
|
||||||
return wxMUTEX_NO_ERROR;
|
return wxMUTEX_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
class wxConditionInternal {
|
//--------------------------------------------------------------------
|
||||||
|
// wxCondition (Posix implementation)
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
|
class wxConditionInternal
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
// TODO: internal handle
|
pthread_cond_t p_condition;
|
||||||
int waiters;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
wxCondition::wxCondition()
|
wxCondition::wxCondition()
|
||||||
{
|
{
|
||||||
p_internal = new wxConditionInternal;
|
p_internal = new wxConditionInternal;
|
||||||
// TODO: create internal handle
|
pthread_cond_init(&(p_internal->p_condition), NULL);
|
||||||
p_internal->waiters = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxCondition::~wxCondition()
|
wxCondition::~wxCondition()
|
||||||
{
|
{
|
||||||
// TODO: destroy internal handle
|
pthread_cond_destroy(&(p_internal->p_condition));
|
||||||
|
delete p_internal;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxCondition::Wait(wxMutex& mutex)
|
void wxCondition::Wait(wxMutex& mutex)
|
||||||
{
|
{
|
||||||
mutex.Unlock();
|
pthread_cond_wait(&(p_internal->p_condition), &(mutex.p_internal->p_mutex));
|
||||||
p_internal->waiters++;
|
|
||||||
// TODO wait here
|
|
||||||
p_internal->waiters--;
|
|
||||||
mutex.Lock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxCondition::Wait(wxMutex& mutex, unsigned long sec,
|
bool wxCondition::Wait(wxMutex& mutex, unsigned long sec, unsigned long nsec)
|
||||||
unsigned long nsec)
|
|
||||||
{
|
{
|
||||||
mutex.Unlock();
|
struct timespec tspec;
|
||||||
p_internal->waiters++;
|
|
||||||
|
|
||||||
// TODO wait here
|
tspec.tv_sec = time(NULL)+sec;
|
||||||
p_internal->waiters--;
|
tspec.tv_nsec = nsec;
|
||||||
mutex.Lock();
|
return (pthread_cond_timedwait(&(p_internal->p_condition), &(mutex.p_internal->p_mutex), &tspec) != ETIMEDOUT);
|
||||||
|
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxCondition::Signal()
|
void wxCondition::Signal()
|
||||||
{
|
{
|
||||||
// TODO
|
pthread_cond_signal(&(p_internal->p_condition));
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxCondition::Broadcast()
|
void wxCondition::Broadcast()
|
||||||
{
|
{
|
||||||
// TODO
|
pthread_cond_broadcast(&(p_internal->p_condition));
|
||||||
}
|
}
|
||||||
|
|
||||||
class wxThreadInternal {
|
//--------------------------------------------------------------------
|
||||||
|
// wxThread (Posix implementation)
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
|
class wxThreadInternal
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
// TODO
|
wxThreadInternal() { state = STATE_IDLE; }
|
||||||
|
~wxThreadInternal() {}
|
||||||
|
static void *PthreadStart(void *ptr);
|
||||||
|
pthread_t thread_id;
|
||||||
|
int state;
|
||||||
|
int prio;
|
||||||
|
int defer_destroy;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void *wxThreadInternal::PthreadStart(void *ptr)
|
||||||
|
{
|
||||||
|
wxThread *thread = (wxThread *)ptr;
|
||||||
|
|
||||||
|
// Call the main entry
|
||||||
|
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
|
||||||
|
void* status = thread->Entry();
|
||||||
|
|
||||||
|
thread->Exit(status);
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
wxThreadError wxThread::Create()
|
wxThreadError wxThread::Create()
|
||||||
{
|
{
|
||||||
// TODO
|
pthread_attr_t a;
|
||||||
|
int min_prio, max_prio, p;
|
||||||
|
struct sched_param sp;
|
||||||
|
|
||||||
|
if (p_internal->state != STATE_IDLE)
|
||||||
|
return wxTHREAD_RUNNING;
|
||||||
|
|
||||||
|
// Change thread priority
|
||||||
|
pthread_attr_init(&a);
|
||||||
|
pthread_attr_getschedpolicy(&a, &p);
|
||||||
|
|
||||||
|
min_prio = sched_get_priority_min(p);
|
||||||
|
max_prio = sched_get_priority_max(p);
|
||||||
|
|
||||||
|
pthread_attr_getschedparam(&a, &sp);
|
||||||
|
sp.sched_priority = min_prio +
|
||||||
|
(p_internal->prio*(max_prio-min_prio))/100;
|
||||||
|
pthread_attr_setschedparam(&a, &sp);
|
||||||
|
|
||||||
|
// this is the point of no return
|
||||||
|
p_internal->state = STATE_RUNNING;
|
||||||
|
if (pthread_create(&p_internal->thread_id, &a,
|
||||||
|
wxThreadInternal::PthreadStart, (void *)this) != 0)
|
||||||
|
{
|
||||||
|
p_internal->state = STATE_IDLE;
|
||||||
|
pthread_attr_destroy(&a);
|
||||||
|
return wxTHREAD_NO_RESOURCE;
|
||||||
|
}
|
||||||
|
pthread_attr_destroy(&a);
|
||||||
|
|
||||||
return wxTHREAD_NO_ERROR;
|
return wxTHREAD_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxThread::SetPriority(int prio)
|
||||||
|
{
|
||||||
|
if (p_internal->state == STATE_RUNNING)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (prio > 100) prio = 100;
|
||||||
|
|
||||||
|
if (prio < 0) prio = 0;
|
||||||
|
|
||||||
|
p_internal->prio = prio;
|
||||||
|
}
|
||||||
|
|
||||||
|
int wxThread::GetPriority() const
|
||||||
|
{
|
||||||
|
return p_internal->prio;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxThread::DeferDestroy(bool on)
|
||||||
|
{
|
||||||
|
if (on)
|
||||||
|
pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, NULL);
|
||||||
|
else
|
||||||
|
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
wxThreadError wxThread::Destroy()
|
wxThreadError wxThread::Destroy()
|
||||||
{
|
{
|
||||||
// TODO
|
int res = 0;
|
||||||
|
|
||||||
|
if (p_internal->state == STATE_RUNNING)
|
||||||
|
{
|
||||||
|
res = pthread_cancel(p_internal->thread_id);
|
||||||
|
if (res == 0)
|
||||||
|
p_internal->state = STATE_CANCELED;
|
||||||
|
}
|
||||||
|
|
||||||
return wxTHREAD_NO_ERROR;
|
return wxTHREAD_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxThreadError wxThread::Pause()
|
wxThreadError wxThread::Pause()
|
||||||
{
|
{
|
||||||
// TODO
|
if (p_internal->state != STATE_RUNNING)
|
||||||
|
return wxTHREAD_NOT_RUNNING;
|
||||||
|
|
||||||
|
if (!p_internal->defer_destroy)
|
||||||
|
return wxTHREAD_MISC_ERROR;
|
||||||
|
|
||||||
|
p_internal->state = STATE_PAUSING;
|
||||||
return wxTHREAD_NO_ERROR;
|
return wxTHREAD_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxThreadError wxThread::Resume()
|
wxThreadError wxThread::Resume()
|
||||||
{
|
{
|
||||||
// TODO
|
if (p_internal->state == STATE_PAUSING || p_internal->state == STATE_PAUSED)
|
||||||
|
p_internal->state = STATE_RUNNING;
|
||||||
|
|
||||||
return wxTHREAD_NO_ERROR;
|
return wxTHREAD_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxThread::Exit(void *status)
|
|
||||||
{
|
|
||||||
// TODO
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxThread::SetPriority(int prio)
|
|
||||||
{
|
|
||||||
// TODO
|
|
||||||
}
|
|
||||||
|
|
||||||
int wxThread::GetPriority() const
|
|
||||||
{
|
|
||||||
// TODO
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxThread::DeferDestroy(bool on)
|
|
||||||
{
|
|
||||||
// TODO
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxThread::TestDestroy()
|
|
||||||
{
|
|
||||||
// TODO
|
|
||||||
}
|
|
||||||
|
|
||||||
void *wxThread::Join()
|
void *wxThread::Join()
|
||||||
{
|
{
|
||||||
// TODO
|
void* status = 0;
|
||||||
return (void*) NULL;
|
|
||||||
|
if (p_internal->state != STATE_IDLE)
|
||||||
|
{
|
||||||
|
bool do_unlock = wxThread::IsMain();
|
||||||
|
|
||||||
|
while (p_internal->state == STATE_RUNNING)
|
||||||
|
wxYield();
|
||||||
|
|
||||||
|
if (do_unlock) wxMainMutex->Unlock();
|
||||||
|
|
||||||
|
pthread_join(p_internal->thread_id, &status);
|
||||||
|
|
||||||
|
if (do_unlock) wxMainMutex->Lock();
|
||||||
|
|
||||||
|
p_internal->state = STATE_IDLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long wxThread::GetID() const
|
unsigned long wxThread::GetID() const
|
||||||
{
|
{
|
||||||
// TODO
|
return p_internal->thread_id;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
void wxThread::Exit(void *status)
|
||||||
wxThread *wxThread::GetThreadFromID(unsigned long id)
|
|
||||||
{
|
{
|
||||||
// TODO
|
wxThread* ptr = this;
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
bool wxThread::IsAlive() const
|
/* THREAD_SEND_EXIT_MSG(ptr); TODO for Xt */
|
||||||
{
|
|
||||||
// TODO
|
p_internal->state = STATE_EXITED;
|
||||||
return FALSE;
|
pthread_exit(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxThread::IsRunning() const
|
void wxThread::TestDestroy()
|
||||||
{
|
{
|
||||||
// TODO
|
if (p_internal->state == STATE_PAUSING)
|
||||||
return FALSE;
|
{
|
||||||
|
p_internal->state = STATE_PAUSED;
|
||||||
|
while (p_internal->state == STATE_PAUSED)
|
||||||
|
{
|
||||||
|
pthread_testcancel();
|
||||||
|
usleep(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pthread_testcancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxThread::IsMain()
|
bool wxThread::IsMain()
|
||||||
{
|
{
|
||||||
// TODO
|
return (bool)pthread_equal(pthread_self(), p_mainid);
|
||||||
return FALSE;
|
}
|
||||||
|
|
||||||
|
bool wxThread::IsRunning() const
|
||||||
|
{
|
||||||
|
return (p_internal->state == STATE_RUNNING);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxThread::IsAlive() const
|
||||||
|
{
|
||||||
|
return (p_internal->state == STATE_RUNNING) ||
|
||||||
|
(p_internal->state == STATE_PAUSING) ||
|
||||||
|
(p_internal->state == STATE_PAUSED);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxThread::wxThread()
|
wxThread::wxThread()
|
||||||
{
|
{
|
||||||
p_internal = new wxThreadInternal();
|
p_internal = new wxThreadInternal();
|
||||||
|
|
||||||
// TODO
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxThread::~wxThread()
|
wxThread::~wxThread()
|
||||||
@@ -239,23 +405,33 @@ void wxThread::OnExit()
|
|||||||
Join();
|
Join();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Automatic initialization
|
//--------------------------------------------------------------------
|
||||||
class wxThreadModule : public wxModule {
|
// wxThreadModule
|
||||||
DECLARE_DYNAMIC_CLASS(wxThreadModule)
|
//--------------------------------------------------------------------
|
||||||
public:
|
|
||||||
virtual bool OnInit() {
|
|
||||||
/* TODO p_mainid = GetCurrentThread(); */
|
|
||||||
wxMainMutex = new wxMutex();
|
|
||||||
wxMainMutex->Lock();
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Global cleanup
|
class wxThreadModule : public wxModule
|
||||||
virtual void OnExit() {
|
{
|
||||||
wxMainMutex->Unlock();
|
DECLARE_DYNAMIC_CLASS(wxThreadModule)
|
||||||
delete wxMainMutex;
|
|
||||||
|
public:
|
||||||
|
virtual bool OnInit()
|
||||||
|
{
|
||||||
|
wxMainMutex = new wxMutex();
|
||||||
|
wxThreadGuiInit();
|
||||||
|
p_mainid = pthread_self();
|
||||||
|
wxMainMutex->Lock();
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void OnExit()
|
||||||
|
{
|
||||||
|
wxMainMutex->Unlock();
|
||||||
|
wxThreadGuiExit();
|
||||||
|
delete wxMainMutex;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxThreadModule, wxModule)
|
IMPLEMENT_DYNAMIC_CLASS(wxThreadModule, wxModule)
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user