]>
git.saurik.com Git - wxWidgets.git/blob - src/motif/thread.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxThread Implementation. For Unix ports, see e.g. src/gtk
4 // Author: Original from Wolfram Gloger/Guilhem Lavaux
8 // Copyright: (c) Wolfram Gloger (1996, 1997); Guilhem Lavaux (1998)
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "thread.h"
16 #include "wx/module.h"
17 #include "wx/thread.h"
27 /////////////////////////////////////////////////////////////////////////////
29 /////////////////////////////////////////////////////////////////////////////
31 wxMutex
*wxMainMutex
; // controls access to all GUI functions
33 /////////////////////////////////////////////////////////////////////////////
34 // Windows implementation
35 /////////////////////////////////////////////////////////////////////////////
37 class wxMutexInternal
{
39 // TODO: internal mutex handle
44 p_internal
= new wxMutexInternal
;
45 // TODO: create internal mutext handle
52 wxDebugMsg("wxMutex warning: freeing a locked mutex (%d locks)\n", m_locked
);
53 // TODO: free internal mutext handle
56 wxMutexError
wxMutex::Lock()
60 return wxMUTEX_NO_ERROR
;
63 wxMutexError
wxMutex::TryLock()
67 return wxMUTEX_NO_ERROR
;
70 wxMutexError
wxMutex::Unlock()
76 return wxMUTEX_NO_ERROR
;
79 class wxConditionInternal
{
81 // TODO: internal handle
85 wxCondition::wxCondition()
87 p_internal
= new wxConditionInternal
;
88 // TODO: create internal handle
89 p_internal
->waiters
= 0;
92 wxCondition::~wxCondition()
94 // TODO: destroy internal handle
97 void wxCondition::Wait(wxMutex
& mutex
)
100 p_internal
->waiters
++;
102 p_internal
->waiters
--;
106 bool wxCondition::Wait(wxMutex
& mutex
, unsigned long sec
,
110 p_internal
->waiters
++;
113 p_internal
->waiters
--;
119 void wxCondition::Signal()
124 void wxCondition::Broadcast()
129 class wxThreadInternal
{
134 wxThreadError
wxThread::Create()
137 return wxTHREAD_NO_ERROR
;
140 wxThreadError
wxThread::Destroy()
143 return wxTHREAD_NO_ERROR
;
146 wxThreadError
wxThread::Pause()
149 return wxTHREAD_NO_ERROR
;
152 wxThreadError
wxThread::Resume()
155 return wxTHREAD_NO_ERROR
;
158 void wxThread::Exit(void *status
)
163 void wxThread::SetPriority(int prio
)
168 int wxThread::GetPriority() const
174 void wxThread::DeferDestroy(bool on
)
179 void wxThread::TestDestroy()
184 void *wxThread::Join()
190 unsigned long wxThread::GetID() const
197 wxThread *wxThread::GetThreadFromID(unsigned long id)
204 bool wxThread::IsAlive() const
210 bool wxThread::IsRunning() const
216 bool wxThread::IsMain()
224 p_internal
= new wxThreadInternal();
229 wxThread::~wxThread()
236 // The default callback just joins the thread and throws away the result.
237 void wxThread::OnExit()
242 // Automatic initialization
243 class wxThreadModule
: public wxModule
{
244 DECLARE_DYNAMIC_CLASS(wxThreadModule
)
246 virtual bool OnInit() {
247 /* TODO p_mainid = GetCurrentThread(); */
248 wxMainMutex
= new wxMutex();
254 virtual void OnExit() {
255 wxMainMutex
->Unlock();
260 IMPLEMENT_DYNAMIC_CLASS(wxThreadModule
, wxModule
)