Makefile tweaks
Threads work now under wxGTK and glibc 2 git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1266 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
2
Makefile
2
Makefile
@@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
SHELL=/bin/sh
|
SHELL=/bin/sh
|
||||||
|
|
||||||
|
DIRS=src
|
||||||
|
|
||||||
#if DIRS are defind make only executes in these diretories
|
#if DIRS are defind make only executes in these diretories
|
||||||
all::
|
all::
|
||||||
@if test "x$(DIRS)" = x; then \
|
@if test "x$(DIRS)" = x; then \
|
||||||
|
13
configure.in
13
configure.in
@@ -61,6 +61,8 @@ main ()
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (gtk_minor_version > 0) return FALSE;
|
||||||
|
|
||||||
return !((gtk_major_version > major) ||
|
return !((gtk_major_version > major) ||
|
||||||
((gtk_major_version == major) && (gtk_minor_version > minor)) ||
|
((gtk_major_version == major) && (gtk_minor_version > minor)) ||
|
||||||
((gtk_major_version == major) && (gtk_minor_version == minor) && (gtk_micro_version >= micro)));
|
((gtk_major_version == major) && (gtk_minor_version == minor) && (gtk_micro_version >= micro)));
|
||||||
@@ -266,6 +268,9 @@ SEARCH_INCLUDE="\
|
|||||||
/usr/XFree86/include/X11 \
|
/usr/XFree86/include/X11 \
|
||||||
\
|
\
|
||||||
/usr/include \
|
/usr/include \
|
||||||
|
/usr/include/gtk \
|
||||||
|
/usr/include/gdk \
|
||||||
|
/usr/include/glib \
|
||||||
/usr/local/include \
|
/usr/local/include \
|
||||||
/usr/unsupported/include \
|
/usr/unsupported/include \
|
||||||
/usr/athena/include \
|
/usr/athena/include \
|
||||||
@@ -1022,7 +1027,7 @@ if test "$wxUSE_GTK" = 1; then
|
|||||||
AM_PATH_GTK(1.0.4, [
|
AM_PATH_GTK(1.0.4, [
|
||||||
GUI_TK_INCLUDE="$GTK_CFLAGS"
|
GUI_TK_INCLUDE="$GTK_CFLAGS"
|
||||||
GUI_TK_LIBRARY="$GTK_LIBS"
|
GUI_TK_LIBRARY="$GTK_LIBS"
|
||||||
], AC_MSG_ERROR(Is gtk-config in path and GTK+ is version 1.0.4?))
|
], AC_MSG_ERROR(Is gtk-config in path and GTK+ is version 1.0.4 up-to 1.0.6?))
|
||||||
TOOLKIT=GTK
|
TOOLKIT=GTK
|
||||||
TOOLKIT_DEF=__WXGTK__
|
TOOLKIT_DEF=__WXGTK__
|
||||||
WX_LINK=-lwx_gtk_1_0
|
WX_LINK=-lwx_gtk_1_0
|
||||||
@@ -1450,10 +1455,8 @@ if test "$wxUSE_THREADS" = "1"; then
|
|||||||
THREADS_LINK="-lpthread"
|
THREADS_LINK="-lpthread"
|
||||||
])
|
])
|
||||||
])
|
])
|
||||||
AC_CHECK_LIB(pthreads, pthread_setcanceltype, [
|
|
||||||
UNIX_THREAD="gtk/threadpsx.cpp"
|
dnl -lposix4 seems to be required on Solaris
|
||||||
THREADS_LINK="-lpthreads"
|
|
||||||
])
|
|
||||||
|
|
||||||
AC_CHECK_LIB(posix4, printf, [
|
AC_CHECK_LIB(posix4, printf, [
|
||||||
THREADS_LINK="$THREADS_LINK -lposix4"
|
THREADS_LINK="$THREADS_LINK -lposix4"
|
||||||
|
@@ -62,6 +62,8 @@ public:
|
|||||||
virtual void Centre( int direction = wxHORIZONTAL );
|
virtual void Centre( int direction = wxHORIZONTAL );
|
||||||
|
|
||||||
virtual void GetClientSize( int *width, int *height ) const;
|
virtual void GetClientSize( int *width, int *height ) const;
|
||||||
|
wxSize GetClientSize() const { int w, h; GetClientSize(& w, & h); return wxSize(w, h); }
|
||||||
|
|
||||||
virtual void SetClientSize( int const width, int const height );
|
virtual void SetClientSize( int const width, int const height );
|
||||||
|
|
||||||
virtual void SetSize( int x, int y, int width, int height,
|
virtual void SetSize( int x, int y, int width, int height,
|
||||||
|
@@ -62,6 +62,8 @@ public:
|
|||||||
virtual void Centre( int direction = wxHORIZONTAL );
|
virtual void Centre( int direction = wxHORIZONTAL );
|
||||||
|
|
||||||
virtual void GetClientSize( int *width, int *height ) const;
|
virtual void GetClientSize( int *width, int *height ) const;
|
||||||
|
wxSize GetClientSize() const { int w, h; GetClientSize(& w, & h); return wxSize(w, h); }
|
||||||
|
|
||||||
virtual void SetClientSize( int const width, int const height );
|
virtual void SetClientSize( int const width, int const height );
|
||||||
|
|
||||||
virtual void SetSize( int x, int y, int width, int height,
|
virtual void SetSize( int x, int y, int width, int height,
|
||||||
|
@@ -132,8 +132,6 @@ public:
|
|||||||
// Called when thread exits.
|
// Called when thread exits.
|
||||||
virtual void OnExit();
|
virtual void OnExit();
|
||||||
|
|
||||||
// Returns the wxThread object which corresponds to the ID.
|
|
||||||
static wxThread *GetThreadFromID(unsigned long id);
|
|
||||||
protected:
|
protected:
|
||||||
// In case, the DIFFER flag is true, enables another thread to kill this one.
|
// In case, the DIFFER flag is true, enables another thread to kill this one.
|
||||||
void TestDestroy();
|
void TestDestroy();
|
||||||
|
@@ -35,8 +35,6 @@ class MyApp: public wxApp
|
|||||||
bool OnInit(void);
|
bool OnInit(void);
|
||||||
};
|
};
|
||||||
|
|
||||||
wxMutex text_mutex;
|
|
||||||
|
|
||||||
WX_DEFINE_ARRAY(wxThread *,wxArrayThread);
|
WX_DEFINE_ARRAY(wxThread *,wxArrayThread);
|
||||||
|
|
||||||
// Define a new frame type
|
// Define a new frame type
|
||||||
@@ -51,6 +49,7 @@ class MyFrame: public wxFrame
|
|||||||
void OnStartThread(wxCommandEvent& event);
|
void OnStartThread(wxCommandEvent& event);
|
||||||
void OnStopThread(wxCommandEvent& event);
|
void OnStopThread(wxCommandEvent& event);
|
||||||
void OnPauseThread(wxCommandEvent& event);
|
void OnPauseThread(wxCommandEvent& event);
|
||||||
|
void OnSize(wxSizeEvent &event);
|
||||||
bool OnClose(void) { return TRUE; }
|
bool OnClose(void) { return TRUE; }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -85,9 +84,9 @@ void *MyThread::Entry()
|
|||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
TestDestroy();
|
TestDestroy();
|
||||||
text_mutex.Lock();
|
wxMutexGuiEnter();
|
||||||
m_frame->m_txtctrl->WriteText(text);
|
m_frame->m_txtctrl->WriteText(text);
|
||||||
text_mutex.Unlock();
|
wxMutexGuiLeave();
|
||||||
wxSleep(1);
|
wxSleep(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,6 +107,7 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
|||||||
EVT_MENU(TEST_START_THREAD, MyFrame::OnStartThread)
|
EVT_MENU(TEST_START_THREAD, MyFrame::OnStartThread)
|
||||||
EVT_MENU(TEST_STOP_THREAD, MyFrame::OnStopThread)
|
EVT_MENU(TEST_STOP_THREAD, MyFrame::OnStopThread)
|
||||||
EVT_MENU(TEST_PAUSE_THREAD, MyFrame::OnPauseThread)
|
EVT_MENU(TEST_PAUSE_THREAD, MyFrame::OnPauseThread)
|
||||||
|
EVT_SIZE(MyFrame::OnSize)
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
// Create a new application object
|
// Create a new application object
|
||||||
@@ -137,7 +137,10 @@ bool MyApp::OnInit(void)
|
|||||||
// Make a panel with a message
|
// Make a panel with a message
|
||||||
wxPanel *panel = new wxPanel( frame, -1, wxPoint(0, 0), wxSize(400, 200), wxTAB_TRAVERSAL );
|
wxPanel *panel = new wxPanel( frame, -1, wxPoint(0, 0), wxSize(400, 200), wxTAB_TRAVERSAL );
|
||||||
|
|
||||||
frame->m_txtctrl = new wxTextCtrl(panel, -1, "", wxPoint(10, 10), wxSize(390, 190),
|
(void)new wxStaticText( panel, -1, "Log window", wxPoint(10,10) );
|
||||||
|
|
||||||
|
|
||||||
|
frame->m_txtctrl = new wxTextCtrl(panel, -1, "", wxPoint(10,30), wxSize(390, 190),
|
||||||
wxTE_MULTILINE);
|
wxTE_MULTILINE);
|
||||||
|
|
||||||
// Show the frame
|
// Show the frame
|
||||||
@@ -174,7 +177,17 @@ void MyFrame::OnStopThread(wxCommandEvent& WXUNUSED(event) )
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MyFrame::OnPauseThread(wxCommandEvent& WXUNUSED(event) )
|
void MyFrame::OnPauseThread(wxCommandEvent& WXUNUSED(event) )
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void MyFrame::OnSize(wxSizeEvent& event )
|
||||||
|
{
|
||||||
|
wxFrame::OnSize(event);
|
||||||
|
|
||||||
|
wxSize size( GetClientSize() );
|
||||||
|
|
||||||
|
m_txtctrl->SetSize( 10, 30, size.x-20, size.y-40 );
|
||||||
|
}
|
||||||
|
|
||||||
void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event) )
|
void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event) )
|
||||||
{
|
{
|
||||||
|
@@ -39,7 +39,8 @@ include @MAKEINCLUDE@
|
|||||||
STATIC_LIBRARY=lib$(LIB_TARGET).a
|
STATIC_LIBRARY=lib$(LIB_TARGET).a
|
||||||
SHARED_LIBRARY=lib$(LIB_TARGET).so.$(LIB_MAJOR).$(LIB_MINOR)
|
SHARED_LIBRARY=lib$(LIB_TARGET).so.$(LIB_MAJOR).$(LIB_MINOR)
|
||||||
|
|
||||||
LIB_CPP_ALL_SRC=$(LIB_CPP_SRC) @GTK_JOYSTICK@ @UNIX_THREAD@
|
LIB_CPP_ALL_SRC=$(LIB_CPP_SRC) @UNIX_THREAD@
|
||||||
|
# @GTK_JOYSTICK@
|
||||||
|
|
||||||
LIB_C_ALL_SRC=$(LIB_C_SRC) @IODBC_C_SRC@ parser.c
|
LIB_C_ALL_SRC=$(LIB_C_SRC) @IODBC_C_SRC@ parser.c
|
||||||
|
|
||||||
|
@@ -474,7 +474,7 @@ bool wxSocketBase::GetPeer(wxSockAddress& addr_man) const
|
|||||||
if (m_fd < 0)
|
if (m_fd < 0)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (getpeername(m_fd, (struct sockaddr *)&my_addr, (int *)&len_addr) < 0)
|
if (getpeername(m_fd, (struct sockaddr *)&my_addr, (socklen_t *)&len_addr) < 0)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
addr_man.Disassemble(&my_addr, len_addr);
|
addr_man.Disassemble(&my_addr, len_addr);
|
||||||
@@ -489,7 +489,7 @@ bool wxSocketBase::GetLocal(wxSockAddress& addr_man) const
|
|||||||
if (m_fd < 0)
|
if (m_fd < 0)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (getsockname(m_fd, (struct sockaddr *)&my_addr, (int *)&len_addr) < 0)
|
if (getsockname(m_fd, (struct sockaddr *)&my_addr, (socklen_t *)&len_addr) < 0)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
addr_man.Disassemble(&my_addr, len_addr);
|
addr_man.Disassemble(&my_addr, len_addr);
|
||||||
|
@@ -22,6 +22,7 @@
|
|||||||
#include "wx/resource.h"
|
#include "wx/resource.h"
|
||||||
#include "wx/module.h"
|
#include "wx/module.h"
|
||||||
#include "wx/image.h"
|
#include "wx/image.h"
|
||||||
|
#include "wx/thread.h"
|
||||||
|
|
||||||
#include "unistd.h"
|
#include "unistd.h"
|
||||||
|
|
||||||
@@ -137,7 +138,9 @@ END_EVENT_TABLE()
|
|||||||
gint wxapp_idle_callback( gpointer WXUNUSED(data) )
|
gint wxapp_idle_callback( gpointer WXUNUSED(data) )
|
||||||
{
|
{
|
||||||
if (wxTheApp) while (wxTheApp->ProcessIdle()) {}
|
if (wxTheApp) while (wxTheApp->ProcessIdle()) {}
|
||||||
|
wxMutexGuiLeave();
|
||||||
usleep(10000);
|
usleep(10000);
|
||||||
|
wxMutexGuiEnter();
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -478,6 +481,3 @@ int wxEntry( int argc, char *argv[] )
|
|||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -37,13 +37,19 @@ ThreadExitProc(gpointer WXUNUSED(client), gint fid,
|
|||||||
{
|
{
|
||||||
wxThread* ptr;
|
wxThread* ptr;
|
||||||
|
|
||||||
|
// printf( "thread exit proc.\n" );
|
||||||
|
|
||||||
if (fid != p_thrd_pipe[0])
|
if (fid != p_thrd_pipe[0])
|
||||||
return;
|
return;
|
||||||
if (read(fid, &ptr, sizeof(ptr)) == sizeof(ptr)) {
|
|
||||||
//fprintf(stderr, "calling OnExit %p\n", ptr);
|
if (read(fid, &ptr, sizeof(ptr)) == sizeof(ptr))
|
||||||
|
{
|
||||||
|
// printf( "calling OnExit %p\n", ptr);
|
||||||
ptr->OnExit();
|
ptr->OnExit();
|
||||||
} else {
|
}
|
||||||
//fprintf(stderr, "this should never happen\n");
|
else
|
||||||
|
{
|
||||||
|
// printf( "this should never happen\n" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,20 +69,6 @@ static void wxThreadGuiExit()
|
|||||||
close(p_thrd_pipe[1]);
|
close(p_thrd_pipe[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef NO_DEFINE_GDK_1_1
|
|
||||||
|
|
||||||
void wxMutexGuiEnter()
|
|
||||||
{
|
|
||||||
gdk_mutex_enter();
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxMutexGuiLeave()
|
|
||||||
{
|
|
||||||
gdk_mutex_leave();
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
void wxMutexGuiEnter()
|
void wxMutexGuiEnter()
|
||||||
{
|
{
|
||||||
wxMainMutex->Lock();
|
wxMainMutex->Lock();
|
||||||
@@ -87,4 +79,3 @@ void wxMutexGuiLeave()
|
|||||||
wxMainMutex->Unlock();
|
wxMainMutex->Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
@@ -5,9 +5,12 @@
|
|||||||
// Modified by:
|
// Modified by:
|
||||||
// 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)
|
||||||
|
// Robert Roebling (1999)
|
||||||
// Licence: wxWindows licence
|
// Licence: wxWindows licence
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#ifdef __GNUG__
|
#ifdef __GNUG__
|
||||||
#pragma implementation "thread.h"
|
#pragma implementation "thread.h"
|
||||||
#endif
|
#endif
|
||||||
@@ -21,7 +24,8 @@
|
|||||||
#include "wx/utils.h"
|
#include "wx/utils.h"
|
||||||
#include "wx/log.h"
|
#include "wx/log.h"
|
||||||
|
|
||||||
enum thread_state {
|
enum thread_state
|
||||||
|
{
|
||||||
STATE_IDLE = 0,
|
STATE_IDLE = 0,
|
||||||
STATE_RUNNING,
|
STATE_RUNNING,
|
||||||
STATE_PAUSING,
|
STATE_PAUSING,
|
||||||
@@ -30,26 +34,26 @@ enum thread_state {
|
|||||||
STATE_EXITED
|
STATE_EXITED
|
||||||
};
|
};
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
//--------------------------------------------------------------------
|
||||||
// Static variables
|
// global data
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
static pthread_t p_mainid;
|
static pthread_t p_mainid;
|
||||||
static wxMutex p_list_mutex;
|
|
||||||
static wxList p_threads_list;
|
|
||||||
|
|
||||||
wxMutex *wxMainMutex; // controls access to all GUI functions
|
wxMutex *wxMainMutex; // controls access to all GUI functions
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
//--------------------------------------------------------------------
|
||||||
// GUI thread manager
|
// common GUI thread code
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
#include "threadgui.inc"
|
#include "threadgui.inc"
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
//--------------------------------------------------------------------
|
||||||
// wxThread: Posix Thread implementation (Mutex)
|
// wxMutex (Posix implementation)
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
class wxMutexInternal {
|
class wxMutexInternal
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
pthread_mutex_t p_mutex;
|
pthread_mutex_t p_mutex;
|
||||||
};
|
};
|
||||||
@@ -77,6 +81,7 @@ wxMutexError wxMutex::Lock()
|
|||||||
err = pthread_mutex_lock(&(p_internal->p_mutex));
|
err = pthread_mutex_lock(&(p_internal->p_mutex));
|
||||||
if (err == EDEADLK)
|
if (err == EDEADLK)
|
||||||
return MUTEX_DEAD_LOCK;
|
return MUTEX_DEAD_LOCK;
|
||||||
|
|
||||||
m_locked++;
|
m_locked++;
|
||||||
return MUTEX_NO_ERROR;
|
return MUTEX_NO_ERROR;
|
||||||
}
|
}
|
||||||
@@ -87,8 +92,10 @@ wxMutexError wxMutex::TryLock()
|
|||||||
|
|
||||||
if (m_locked)
|
if (m_locked)
|
||||||
return MUTEX_BUSY;
|
return MUTEX_BUSY;
|
||||||
|
|
||||||
err = pthread_mutex_trylock(&(p_internal->p_mutex));
|
err = pthread_mutex_trylock(&(p_internal->p_mutex));
|
||||||
switch (err) {
|
switch (err)
|
||||||
|
{
|
||||||
case EBUSY: return MUTEX_BUSY;
|
case EBUSY: return MUTEX_BUSY;
|
||||||
}
|
}
|
||||||
m_locked++;
|
m_locked++;
|
||||||
@@ -101,15 +108,17 @@ wxMutexError wxMutex::Unlock()
|
|||||||
m_locked--;
|
m_locked--;
|
||||||
else
|
else
|
||||||
return MUTEX_UNLOCKED;
|
return MUTEX_UNLOCKED;
|
||||||
|
|
||||||
pthread_mutex_unlock(&(p_internal->p_mutex));
|
pthread_mutex_unlock(&(p_internal->p_mutex));
|
||||||
return MUTEX_NO_ERROR;
|
return MUTEX_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
//--------------------------------------------------------------------
|
||||||
// wxThread: Posix Thread implementation (Condition)
|
// wxCondition (Posix implementation)
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
class wxConditionInternal {
|
class wxConditionInternal
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
pthread_cond_t p_condition;
|
pthread_cond_t p_condition;
|
||||||
};
|
};
|
||||||
@@ -150,11 +159,12 @@ void wxCondition::Broadcast()
|
|||||||
pthread_cond_broadcast(&(p_internal->p_condition));
|
pthread_cond_broadcast(&(p_internal->p_condition));
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
//--------------------------------------------------------------------
|
||||||
// wxThread: Posix Thread implementation (Thread)
|
// wxThread (Posix implementation)
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
class wxThreadInternal {
|
class wxThreadInternal
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
wxThreadInternal() { state = STATE_IDLE; }
|
wxThreadInternal() { state = STATE_IDLE; }
|
||||||
~wxThreadInternal() {}
|
~wxThreadInternal() {}
|
||||||
@@ -163,19 +173,12 @@ public:
|
|||||||
int state;
|
int state;
|
||||||
int prio;
|
int prio;
|
||||||
int defer_destroy;
|
int defer_destroy;
|
||||||
int id;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void *wxThreadInternal::PthreadStart(void *ptr)
|
void *wxThreadInternal::PthreadStart(void *ptr)
|
||||||
{
|
{
|
||||||
wxThread *thread = (wxThread *)ptr;
|
wxThread *thread = (wxThread *)ptr;
|
||||||
|
|
||||||
// Add the current thread to the list
|
|
||||||
p_list_mutex.Lock();
|
|
||||||
thread->p_internal->id = p_threads_list.Number();
|
|
||||||
p_threads_list.Append((wxObject *)thread);
|
|
||||||
p_list_mutex.Unlock();
|
|
||||||
|
|
||||||
// Call the main entry
|
// Call the main entry
|
||||||
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
|
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
|
||||||
void* status = thread->Entry();
|
void* status = thread->Entry();
|
||||||
@@ -209,7 +212,8 @@ wxThreadError wxThread::Create()
|
|||||||
// this is the point of no return
|
// this is the point of no return
|
||||||
p_internal->state = STATE_RUNNING;
|
p_internal->state = STATE_RUNNING;
|
||||||
if (pthread_create(&p_internal->thread_id, &a,
|
if (pthread_create(&p_internal->thread_id, &a,
|
||||||
wxThreadInternal::PthreadStart, (void *)this) != 0) {
|
wxThreadInternal::PthreadStart, (void *)this) != 0)
|
||||||
|
{
|
||||||
p_internal->state = STATE_IDLE;
|
p_internal->state = STATE_IDLE;
|
||||||
pthread_attr_destroy(&a);
|
pthread_attr_destroy(&a);
|
||||||
return THREAD_NO_RESOURCE;
|
return THREAD_NO_RESOURCE;
|
||||||
@@ -224,10 +228,10 @@ void wxThread::SetPriority(int prio)
|
|||||||
if (p_internal->state == STATE_RUNNING)
|
if (p_internal->state == STATE_RUNNING)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (prio > 100)
|
if (prio > 100) prio = 100;
|
||||||
prio = 100;
|
|
||||||
if (prio < 0)
|
if (prio < 0) prio = 0;
|
||||||
prio = 0;
|
|
||||||
p_internal->prio = prio;
|
p_internal->prio = prio;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -248,7 +252,8 @@ wxThreadError wxThread::Destroy()
|
|||||||
{
|
{
|
||||||
int res = 0;
|
int res = 0;
|
||||||
|
|
||||||
if (p_internal->state == STATE_RUNNING) {
|
if (p_internal->state == STATE_RUNNING)
|
||||||
|
{
|
||||||
res = pthread_cancel(p_internal->thread_id);
|
res = pthread_cancel(p_internal->thread_id);
|
||||||
if (res == 0)
|
if (res == 0)
|
||||||
p_internal->state = STATE_CANCELED;
|
p_internal->state = STATE_CANCELED;
|
||||||
@@ -281,39 +286,28 @@ void *wxThread::Join()
|
|||||||
{
|
{
|
||||||
void* status = 0;
|
void* status = 0;
|
||||||
|
|
||||||
if (p_internal->state != STATE_IDLE) {
|
if (p_internal->state != STATE_IDLE)
|
||||||
|
{
|
||||||
bool do_unlock = wxThread::IsMain();
|
bool do_unlock = wxThread::IsMain();
|
||||||
|
|
||||||
while (p_internal->state == STATE_RUNNING)
|
while (p_internal->state == STATE_RUNNING)
|
||||||
wxYield();
|
wxYield();
|
||||||
|
|
||||||
if (do_unlock)
|
if (do_unlock) wxMainMutex->Unlock();
|
||||||
wxMainMutex->Unlock();
|
|
||||||
pthread_join(p_internal->thread_id, &status);
|
|
||||||
if (do_unlock)
|
|
||||||
wxMainMutex->Lock();
|
|
||||||
|
|
||||||
p_list_mutex.Lock();
|
pthread_join(p_internal->thread_id, &status);
|
||||||
delete p_threads_list.Nth(p_internal->id);
|
|
||||||
p_list_mutex.Unlock();
|
if (do_unlock) wxMainMutex->Lock();
|
||||||
|
|
||||||
p_internal->state = STATE_IDLE;
|
p_internal->state = STATE_IDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long wxThread::GetID() const
|
unsigned long wxThread::GetID() const
|
||||||
{
|
{
|
||||||
return p_internal->id;
|
return p_internal->thread_id;
|
||||||
}
|
|
||||||
|
|
||||||
wxThread *wxThread::GetThreadFromID(unsigned long id)
|
|
||||||
{
|
|
||||||
wxNode *node = p_threads_list.Nth(id);
|
|
||||||
|
|
||||||
if (!node)
|
|
||||||
return NULL;
|
|
||||||
return (wxThread *)node->Data();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxThread::Exit(void *status)
|
void wxThread::Exit(void *status)
|
||||||
@@ -327,9 +321,11 @@ void wxThread::Exit(void *status)
|
|||||||
|
|
||||||
void wxThread::TestDestroy()
|
void wxThread::TestDestroy()
|
||||||
{
|
{
|
||||||
if (p_internal->state == STATE_PAUSING) {
|
if (p_internal->state == STATE_PAUSING)
|
||||||
|
{
|
||||||
p_internal->state = STATE_PAUSED;
|
p_internal->state = STATE_PAUSED;
|
||||||
while (p_internal->state == STATE_PAUSED) {
|
while (p_internal->state == STATE_PAUSED)
|
||||||
|
{
|
||||||
pthread_testcancel();
|
pthread_testcancel();
|
||||||
usleep(1);
|
usleep(1);
|
||||||
}
|
}
|
||||||
@@ -372,21 +368,27 @@ void wxThread::OnExit()
|
|||||||
Join();
|
Join();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Automatic initialization
|
//--------------------------------------------------------------------
|
||||||
class wxThreadModule : public wxModule {
|
// wxThreadModule
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
|
class wxThreadModule : public wxModule
|
||||||
|
{
|
||||||
DECLARE_DYNAMIC_CLASS(wxThreadModule)
|
DECLARE_DYNAMIC_CLASS(wxThreadModule)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual bool OnInit() {
|
virtual bool OnInit()
|
||||||
|
{
|
||||||
wxMainMutex = new wxMutex();
|
wxMainMutex = new wxMutex();
|
||||||
wxThreadGuiInit();
|
wxThreadGuiInit();
|
||||||
p_mainid = pthread_self();
|
p_mainid = pthread_self();
|
||||||
// p_threads_list = wxList(wxKEY_INTEGER);
|
|
||||||
wxMainMutex->Lock();
|
wxMainMutex->Lock();
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void OnExit() {
|
virtual void OnExit()
|
||||||
|
{
|
||||||
wxMainMutex->Unlock();
|
wxMainMutex->Unlock();
|
||||||
wxThreadGuiExit();
|
wxThreadGuiExit();
|
||||||
delete wxMainMutex;
|
delete wxMainMutex;
|
||||||
@@ -394,3 +396,4 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxThreadModule, wxModule)
|
IMPLEMENT_DYNAMIC_CLASS(wxThreadModule, wxModule)
|
||||||
|
|
||||||
|
@@ -22,6 +22,7 @@
|
|||||||
#include "wx/resource.h"
|
#include "wx/resource.h"
|
||||||
#include "wx/module.h"
|
#include "wx/module.h"
|
||||||
#include "wx/image.h"
|
#include "wx/image.h"
|
||||||
|
#include "wx/thread.h"
|
||||||
|
|
||||||
#include "unistd.h"
|
#include "unistd.h"
|
||||||
|
|
||||||
@@ -137,7 +138,9 @@ END_EVENT_TABLE()
|
|||||||
gint wxapp_idle_callback( gpointer WXUNUSED(data) )
|
gint wxapp_idle_callback( gpointer WXUNUSED(data) )
|
||||||
{
|
{
|
||||||
if (wxTheApp) while (wxTheApp->ProcessIdle()) {}
|
if (wxTheApp) while (wxTheApp->ProcessIdle()) {}
|
||||||
|
wxMutexGuiLeave();
|
||||||
usleep(10000);
|
usleep(10000);
|
||||||
|
wxMutexGuiEnter();
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -478,6 +481,3 @@ int wxEntry( int argc, char *argv[] )
|
|||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -37,13 +37,19 @@ ThreadExitProc(gpointer WXUNUSED(client), gint fid,
|
|||||||
{
|
{
|
||||||
wxThread* ptr;
|
wxThread* ptr;
|
||||||
|
|
||||||
|
// printf( "thread exit proc.\n" );
|
||||||
|
|
||||||
if (fid != p_thrd_pipe[0])
|
if (fid != p_thrd_pipe[0])
|
||||||
return;
|
return;
|
||||||
if (read(fid, &ptr, sizeof(ptr)) == sizeof(ptr)) {
|
|
||||||
//fprintf(stderr, "calling OnExit %p\n", ptr);
|
if (read(fid, &ptr, sizeof(ptr)) == sizeof(ptr))
|
||||||
|
{
|
||||||
|
// printf( "calling OnExit %p\n", ptr);
|
||||||
ptr->OnExit();
|
ptr->OnExit();
|
||||||
} else {
|
}
|
||||||
//fprintf(stderr, "this should never happen\n");
|
else
|
||||||
|
{
|
||||||
|
// printf( "this should never happen\n" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,20 +69,6 @@ static void wxThreadGuiExit()
|
|||||||
close(p_thrd_pipe[1]);
|
close(p_thrd_pipe[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef NO_DEFINE_GDK_1_1
|
|
||||||
|
|
||||||
void wxMutexGuiEnter()
|
|
||||||
{
|
|
||||||
gdk_mutex_enter();
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxMutexGuiLeave()
|
|
||||||
{
|
|
||||||
gdk_mutex_leave();
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
void wxMutexGuiEnter()
|
void wxMutexGuiEnter()
|
||||||
{
|
{
|
||||||
wxMainMutex->Lock();
|
wxMainMutex->Lock();
|
||||||
@@ -87,4 +79,3 @@ void wxMutexGuiLeave()
|
|||||||
wxMainMutex->Unlock();
|
wxMainMutex->Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
@@ -5,9 +5,12 @@
|
|||||||
// Modified by:
|
// Modified by:
|
||||||
// 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)
|
||||||
|
// Robert Roebling (1999)
|
||||||
// Licence: wxWindows licence
|
// Licence: wxWindows licence
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#ifdef __GNUG__
|
#ifdef __GNUG__
|
||||||
#pragma implementation "thread.h"
|
#pragma implementation "thread.h"
|
||||||
#endif
|
#endif
|
||||||
@@ -21,7 +24,8 @@
|
|||||||
#include "wx/utils.h"
|
#include "wx/utils.h"
|
||||||
#include "wx/log.h"
|
#include "wx/log.h"
|
||||||
|
|
||||||
enum thread_state {
|
enum thread_state
|
||||||
|
{
|
||||||
STATE_IDLE = 0,
|
STATE_IDLE = 0,
|
||||||
STATE_RUNNING,
|
STATE_RUNNING,
|
||||||
STATE_PAUSING,
|
STATE_PAUSING,
|
||||||
@@ -30,26 +34,26 @@ enum thread_state {
|
|||||||
STATE_EXITED
|
STATE_EXITED
|
||||||
};
|
};
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
//--------------------------------------------------------------------
|
||||||
// Static variables
|
// global data
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
static pthread_t p_mainid;
|
static pthread_t p_mainid;
|
||||||
static wxMutex p_list_mutex;
|
|
||||||
static wxList p_threads_list;
|
|
||||||
|
|
||||||
wxMutex *wxMainMutex; // controls access to all GUI functions
|
wxMutex *wxMainMutex; // controls access to all GUI functions
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
//--------------------------------------------------------------------
|
||||||
// GUI thread manager
|
// common GUI thread code
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
#include "threadgui.inc"
|
#include "threadgui.inc"
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
//--------------------------------------------------------------------
|
||||||
// wxThread: Posix Thread implementation (Mutex)
|
// wxMutex (Posix implementation)
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
class wxMutexInternal {
|
class wxMutexInternal
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
pthread_mutex_t p_mutex;
|
pthread_mutex_t p_mutex;
|
||||||
};
|
};
|
||||||
@@ -77,6 +81,7 @@ wxMutexError wxMutex::Lock()
|
|||||||
err = pthread_mutex_lock(&(p_internal->p_mutex));
|
err = pthread_mutex_lock(&(p_internal->p_mutex));
|
||||||
if (err == EDEADLK)
|
if (err == EDEADLK)
|
||||||
return MUTEX_DEAD_LOCK;
|
return MUTEX_DEAD_LOCK;
|
||||||
|
|
||||||
m_locked++;
|
m_locked++;
|
||||||
return MUTEX_NO_ERROR;
|
return MUTEX_NO_ERROR;
|
||||||
}
|
}
|
||||||
@@ -87,8 +92,10 @@ wxMutexError wxMutex::TryLock()
|
|||||||
|
|
||||||
if (m_locked)
|
if (m_locked)
|
||||||
return MUTEX_BUSY;
|
return MUTEX_BUSY;
|
||||||
|
|
||||||
err = pthread_mutex_trylock(&(p_internal->p_mutex));
|
err = pthread_mutex_trylock(&(p_internal->p_mutex));
|
||||||
switch (err) {
|
switch (err)
|
||||||
|
{
|
||||||
case EBUSY: return MUTEX_BUSY;
|
case EBUSY: return MUTEX_BUSY;
|
||||||
}
|
}
|
||||||
m_locked++;
|
m_locked++;
|
||||||
@@ -101,15 +108,17 @@ wxMutexError wxMutex::Unlock()
|
|||||||
m_locked--;
|
m_locked--;
|
||||||
else
|
else
|
||||||
return MUTEX_UNLOCKED;
|
return MUTEX_UNLOCKED;
|
||||||
|
|
||||||
pthread_mutex_unlock(&(p_internal->p_mutex));
|
pthread_mutex_unlock(&(p_internal->p_mutex));
|
||||||
return MUTEX_NO_ERROR;
|
return MUTEX_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
//--------------------------------------------------------------------
|
||||||
// wxThread: Posix Thread implementation (Condition)
|
// wxCondition (Posix implementation)
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
class wxConditionInternal {
|
class wxConditionInternal
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
pthread_cond_t p_condition;
|
pthread_cond_t p_condition;
|
||||||
};
|
};
|
||||||
@@ -150,11 +159,12 @@ void wxCondition::Broadcast()
|
|||||||
pthread_cond_broadcast(&(p_internal->p_condition));
|
pthread_cond_broadcast(&(p_internal->p_condition));
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
//--------------------------------------------------------------------
|
||||||
// wxThread: Posix Thread implementation (Thread)
|
// wxThread (Posix implementation)
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
class wxThreadInternal {
|
class wxThreadInternal
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
wxThreadInternal() { state = STATE_IDLE; }
|
wxThreadInternal() { state = STATE_IDLE; }
|
||||||
~wxThreadInternal() {}
|
~wxThreadInternal() {}
|
||||||
@@ -163,19 +173,12 @@ public:
|
|||||||
int state;
|
int state;
|
||||||
int prio;
|
int prio;
|
||||||
int defer_destroy;
|
int defer_destroy;
|
||||||
int id;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void *wxThreadInternal::PthreadStart(void *ptr)
|
void *wxThreadInternal::PthreadStart(void *ptr)
|
||||||
{
|
{
|
||||||
wxThread *thread = (wxThread *)ptr;
|
wxThread *thread = (wxThread *)ptr;
|
||||||
|
|
||||||
// Add the current thread to the list
|
|
||||||
p_list_mutex.Lock();
|
|
||||||
thread->p_internal->id = p_threads_list.Number();
|
|
||||||
p_threads_list.Append((wxObject *)thread);
|
|
||||||
p_list_mutex.Unlock();
|
|
||||||
|
|
||||||
// Call the main entry
|
// Call the main entry
|
||||||
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
|
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
|
||||||
void* status = thread->Entry();
|
void* status = thread->Entry();
|
||||||
@@ -209,7 +212,8 @@ wxThreadError wxThread::Create()
|
|||||||
// this is the point of no return
|
// this is the point of no return
|
||||||
p_internal->state = STATE_RUNNING;
|
p_internal->state = STATE_RUNNING;
|
||||||
if (pthread_create(&p_internal->thread_id, &a,
|
if (pthread_create(&p_internal->thread_id, &a,
|
||||||
wxThreadInternal::PthreadStart, (void *)this) != 0) {
|
wxThreadInternal::PthreadStart, (void *)this) != 0)
|
||||||
|
{
|
||||||
p_internal->state = STATE_IDLE;
|
p_internal->state = STATE_IDLE;
|
||||||
pthread_attr_destroy(&a);
|
pthread_attr_destroy(&a);
|
||||||
return THREAD_NO_RESOURCE;
|
return THREAD_NO_RESOURCE;
|
||||||
@@ -224,10 +228,10 @@ void wxThread::SetPriority(int prio)
|
|||||||
if (p_internal->state == STATE_RUNNING)
|
if (p_internal->state == STATE_RUNNING)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (prio > 100)
|
if (prio > 100) prio = 100;
|
||||||
prio = 100;
|
|
||||||
if (prio < 0)
|
if (prio < 0) prio = 0;
|
||||||
prio = 0;
|
|
||||||
p_internal->prio = prio;
|
p_internal->prio = prio;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -248,7 +252,8 @@ wxThreadError wxThread::Destroy()
|
|||||||
{
|
{
|
||||||
int res = 0;
|
int res = 0;
|
||||||
|
|
||||||
if (p_internal->state == STATE_RUNNING) {
|
if (p_internal->state == STATE_RUNNING)
|
||||||
|
{
|
||||||
res = pthread_cancel(p_internal->thread_id);
|
res = pthread_cancel(p_internal->thread_id);
|
||||||
if (res == 0)
|
if (res == 0)
|
||||||
p_internal->state = STATE_CANCELED;
|
p_internal->state = STATE_CANCELED;
|
||||||
@@ -281,39 +286,28 @@ void *wxThread::Join()
|
|||||||
{
|
{
|
||||||
void* status = 0;
|
void* status = 0;
|
||||||
|
|
||||||
if (p_internal->state != STATE_IDLE) {
|
if (p_internal->state != STATE_IDLE)
|
||||||
|
{
|
||||||
bool do_unlock = wxThread::IsMain();
|
bool do_unlock = wxThread::IsMain();
|
||||||
|
|
||||||
while (p_internal->state == STATE_RUNNING)
|
while (p_internal->state == STATE_RUNNING)
|
||||||
wxYield();
|
wxYield();
|
||||||
|
|
||||||
if (do_unlock)
|
if (do_unlock) wxMainMutex->Unlock();
|
||||||
wxMainMutex->Unlock();
|
|
||||||
pthread_join(p_internal->thread_id, &status);
|
|
||||||
if (do_unlock)
|
|
||||||
wxMainMutex->Lock();
|
|
||||||
|
|
||||||
p_list_mutex.Lock();
|
pthread_join(p_internal->thread_id, &status);
|
||||||
delete p_threads_list.Nth(p_internal->id);
|
|
||||||
p_list_mutex.Unlock();
|
if (do_unlock) wxMainMutex->Lock();
|
||||||
|
|
||||||
p_internal->state = STATE_IDLE;
|
p_internal->state = STATE_IDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long wxThread::GetID() const
|
unsigned long wxThread::GetID() const
|
||||||
{
|
{
|
||||||
return p_internal->id;
|
return p_internal->thread_id;
|
||||||
}
|
|
||||||
|
|
||||||
wxThread *wxThread::GetThreadFromID(unsigned long id)
|
|
||||||
{
|
|
||||||
wxNode *node = p_threads_list.Nth(id);
|
|
||||||
|
|
||||||
if (!node)
|
|
||||||
return NULL;
|
|
||||||
return (wxThread *)node->Data();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxThread::Exit(void *status)
|
void wxThread::Exit(void *status)
|
||||||
@@ -327,9 +321,11 @@ void wxThread::Exit(void *status)
|
|||||||
|
|
||||||
void wxThread::TestDestroy()
|
void wxThread::TestDestroy()
|
||||||
{
|
{
|
||||||
if (p_internal->state == STATE_PAUSING) {
|
if (p_internal->state == STATE_PAUSING)
|
||||||
|
{
|
||||||
p_internal->state = STATE_PAUSED;
|
p_internal->state = STATE_PAUSED;
|
||||||
while (p_internal->state == STATE_PAUSED) {
|
while (p_internal->state == STATE_PAUSED)
|
||||||
|
{
|
||||||
pthread_testcancel();
|
pthread_testcancel();
|
||||||
usleep(1);
|
usleep(1);
|
||||||
}
|
}
|
||||||
@@ -372,21 +368,27 @@ void wxThread::OnExit()
|
|||||||
Join();
|
Join();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Automatic initialization
|
//--------------------------------------------------------------------
|
||||||
class wxThreadModule : public wxModule {
|
// wxThreadModule
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
|
class wxThreadModule : public wxModule
|
||||||
|
{
|
||||||
DECLARE_DYNAMIC_CLASS(wxThreadModule)
|
DECLARE_DYNAMIC_CLASS(wxThreadModule)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual bool OnInit() {
|
virtual bool OnInit()
|
||||||
|
{
|
||||||
wxMainMutex = new wxMutex();
|
wxMainMutex = new wxMutex();
|
||||||
wxThreadGuiInit();
|
wxThreadGuiInit();
|
||||||
p_mainid = pthread_self();
|
p_mainid = pthread_self();
|
||||||
// p_threads_list = wxList(wxKEY_INTEGER);
|
|
||||||
wxMainMutex->Lock();
|
wxMainMutex->Lock();
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void OnExit() {
|
virtual void OnExit()
|
||||||
|
{
|
||||||
wxMainMutex->Unlock();
|
wxMainMutex->Unlock();
|
||||||
wxThreadGuiExit();
|
wxThreadGuiExit();
|
||||||
delete wxMainMutex;
|
delete wxMainMutex;
|
||||||
@@ -394,3 +396,4 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxThreadModule, wxModule)
|
IMPLEMENT_DYNAMIC_CLASS(wxThreadModule, wxModule)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user