]>
git.saurik.com Git - wxWidgets.git/blob - src/mac/thread.cpp
8dd23bdce95c2f275b47019824aa22b5615de173
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"
29 /////////////////////////////////////////////////////////////////////////////
31 /////////////////////////////////////////////////////////////////////////////
33 wxMutex
*wxMainMutex
; // controls access to all GUI functions
35 /////////////////////////////////////////////////////////////////////////////
36 // Windows implementation
37 /////////////////////////////////////////////////////////////////////////////
39 class wxMutexInternal
{
41 // TODO: internal mutex handle
46 p_internal
= new wxMutexInternal
;
47 // TODO: create internal mutext handle
54 wxDebugMsg("wxMutex warning: freeing a locked mutex (%d locks)\n", m_locked
);
55 // TODO: free internal mutext handle
58 wxMutexError
wxMutex::Lock()
62 return wxMUTEX_NO_ERROR
;
65 wxMutexError
wxMutex::TryLock()
69 return wxMUTEX_NO_ERROR
;
72 wxMutexError
wxMutex::Unlock()
78 return wxMUTEX_NO_ERROR
;
81 class wxConditionInternal
{
83 // TODO: internal handle
87 wxCondition::wxCondition()
89 p_internal
= new wxConditionInternal
;
90 // TODO: create internal handle
91 p_internal
->waiters
= 0;
94 wxCondition::~wxCondition()
96 // TODO: destroy internal handle
99 void wxCondition::Wait(wxMutex
& mutex
)
102 p_internal
->waiters
++;
104 p_internal
->waiters
--;
108 bool wxCondition::Wait(wxMutex
& mutex
, unsigned long sec
,
112 p_internal
->waiters
++;
115 p_internal
->waiters
--;
121 void wxCondition::Signal()
126 void wxCondition::Broadcast()
131 class wxThreadInternal
{
136 wxThreadError
wxThread::Create()
139 return wxTHREAD_NO_ERROR
;
142 wxThreadError
wxThread::Destroy()
145 return wxTHREAD_NO_ERROR
;
148 wxThreadError
wxThread::Pause()
151 return wxTHREAD_NO_ERROR
;
154 wxThreadError
wxThread::Resume()
157 return wxTHREAD_NO_ERROR
;
160 void wxThread::Exit(void *status
)
165 void wxThread::SetPriority(int prio
)
170 int wxThread::GetPriority() const
176 void wxThread::DeferDestroy(bool on
)
181 void wxThread::TestDestroy()
186 void *wxThread::Join()
192 unsigned long wxThread::GetID() const
198 /* is this needed somewhere ?
199 wxThread *wxThread::GetThreadFromID(unsigned long id)
206 bool wxThread::IsAlive() const
212 bool wxThread::IsRunning() const
218 bool wxThread::IsMain()
226 p_internal
= new wxThreadInternal();
231 wxThread::~wxThread()
238 // The default callback just joins the thread and throws away the result.
239 void wxThread::OnExit()
244 // Automatic initialization
245 class wxThreadModule
: public wxModule
{
246 DECLARE_DYNAMIC_CLASS(wxThreadModule
)
248 virtual bool OnInit() {
249 /* TODO p_mainid = GetCurrentThread(); */
250 wxMainMutex
= new wxMutex();
256 virtual void OnExit() {
257 wxMainMutex
->Unlock();
262 IMPLEMENT_DYNAMIC_CLASS(wxThreadModule
, wxModule
)