]>
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 void wxThread::Exit(void *status
)
151 void wxThread::SetPriority(int prio
)
156 int wxThread::GetPriority() const
162 void wxThread::DeferDestroy(bool on
)
167 void wxThread::TestDestroy()
172 void *wxThread::Join()
178 unsigned long wxThread::GetID() const
184 bool wxThread::IsMain()
192 p_internal
= new wxThreadInternal();
197 wxThread::~wxThread()
204 // The default callback just joins the thread and throws away the result.
205 void wxThread::OnExit()
210 // Automatic initialization
211 class wxThreadModule
: public wxModule
{
212 DECLARE_DYNAMIC_CLASS(wxThreadModule
)
214 virtual bool OnInit() {
215 /* TODO p_mainid = GetCurrentThread(); */
221 virtual void OnExit() {
222 wxMainMutex
.Unlock();
226 IMPLEMENT_DYNAMIC_CLASS(wxThreadModule
, wxModule
)