]>
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"
26 /////////////////////////////////////////////////////////////////////////////
28 /////////////////////////////////////////////////////////////////////////////
30 wxMutex wxMainMutex
; // controls access to all GUI functions
32 /////////////////////////////////////////////////////////////////////////////
33 // Windows implementation
34 /////////////////////////////////////////////////////////////////////////////
36 class wxMutexInternal
{
38 // TODO: internal mutex handle
43 p_internal
= new wxMutexInternal
;
44 // TODO: create internal mutext handle
51 wxDebugMsg("wxMutex warning: freeing a locked mutex (%d locks)\n", m_locked
);
52 // TODO: free internal mutext handle
55 wxMutexError
wxMutex::Lock()
59 return MUTEX_NO_ERROR
;
62 wxMutexError
wxMutex::TryLock()
66 return MUTEX_NO_ERROR
;
69 wxMutexError
wxMutex::Unlock()
75 return MUTEX_NO_ERROR
;
78 class wxConditionInternal
{
80 // TODO: internal handle
84 wxCondition::wxCondition()
86 p_internal
= new wxConditionInternal
;
87 // TODO: create internal handle
88 p_internal
->waiters
= 0;
91 wxCondition::~wxCondition()
93 // TODO: destroy internal handle
96 void wxCondition::Wait(wxMutex
& mutex
)
99 p_internal
->waiters
++;
101 p_internal
->waiters
--;
105 bool wxCondition::Wait(wxMutex
& mutex
, unsigned long sec
,
109 p_internal
->waiters
++;
112 p_internal
->waiters
--;
118 void wxCondition::Signal()
123 void wxCondition::Broadcast()
128 class wxThreadInternal
{
133 wxThreadError
wxThread::Create()
136 return THREAD_NO_ERROR
;
139 wxThreadError
wxThread::Destroy()
142 return THREAD_NO_ERROR
;
145 void wxThread::Exit(void *status
)
150 void wxThread::SetPriority(int prio
)
155 int wxThread::GetPriority() const
161 void wxThread::DeferDestroy(bool on
)
166 void wxThread::TestDestroy()
171 void *wxThread::Join()
177 unsigned long wxThread::GetID() const
183 bool wxThread::IsMain()
190 p_internal
= new wxThreadInternal();
195 wxThread::~wxThread()
202 // The default callback just joins the thread and throws away the result.
203 void wxThread::OnExit()
208 // Automatic initialization
209 class wxThreadModule
: public wxModule
{
210 DECLARE_DYNAMIC_CLASS(wxThreadModule
)
212 virtual bool OnInit() {
213 /* TODO p_mainid = GetCurrentThread(); */
219 virtual void OnExit() {
220 wxMainMutex
.Unlock();
224 IMPLEMENT_DYNAMIC_CLASS(wxThreadModule
, wxModule
)