]>
git.saurik.com Git - wxWidgets.git/blob - src/stubs/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 MUTEX_NO_ERROR
;
63 wxMutexError
wxMutex::TryLock()
67 return MUTEX_NO_ERROR
;
70 wxMutexError
wxMutex::Unlock()
76 return MUTEX_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 THREAD_NO_ERROR
;
140 wxThreadError
wxThread::Destroy()
143 return THREAD_NO_ERROR
;
146 wxThreadError
wxThread::Pause()
149 return THREAD_NO_ERROR
;
152 wxThreadError
wxThread::Resume()
155 return THREAD_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
196 wxThread
*wxThread::GetThreadFromID(unsigned long id
)
202 bool wxThread::IsAlive() const
208 bool wxThread::IsRunning() const
214 bool wxThread::IsMain()
222 p_internal
= new wxThreadInternal();
227 wxThread::~wxThread()
234 // The default callback just joins the thread and throws away the result.
235 void wxThread::OnExit()
240 // Automatic initialization
241 class wxThreadModule
: public wxModule
{
242 DECLARE_DYNAMIC_CLASS(wxThreadModule
)
244 virtual bool OnInit() {
245 /* TODO p_mainid = GetCurrentThread(); */
251 virtual void OnExit() {
252 wxMainMutex
.Unlock();
256 IMPLEMENT_DYNAMIC_CLASS(wxThreadModule
, wxModule
)