]> git.saurik.com Git - wxWidgets.git/blame - src/mac/thread.cpp
Removed Vadim's surplus code in clipboard.
[wxWidgets.git] / src / mac / thread.cpp
CommitLineData
e9576ca5
SC
1/////////////////////////////////////////////////////////////////////////////
2// Name: thread.cpp
3// Purpose: wxThread Implementation. For Unix ports, see e.g. src/gtk
4// Author: Original from Wolfram Gloger/Guilhem Lavaux
5// Modified by:
6// Created: 04/22/98
7// RCS-ID: $Id$
8// Copyright: (c) Wolfram Gloger (1996, 1997); Guilhem Lavaux (1998)
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#ifdef __GNUG__
13#pragma implementation "thread.h"
14#endif
15
16#include "wx/module.h"
17#include "wx/thread.h"
18#include "wx/utils.h"
19
20enum thread_state {
21 STATE_IDLE = 0,
22 STATE_RUNNING,
23 STATE_CANCELED,
24 STATE_EXITED
25};
26
169935ad
SC
27#if wxUSE_THREADS
28
e9576ca5
SC
29/////////////////////////////////////////////////////////////////////////////
30// Static variables
31/////////////////////////////////////////////////////////////////////////////
32
33wxMutex *wxMainMutex; // controls access to all GUI functions
34
35/////////////////////////////////////////////////////////////////////////////
36// Windows implementation
37/////////////////////////////////////////////////////////////////////////////
38
39class wxMutexInternal {
40public:
41 // TODO: internal mutex handle
42};
43
44wxMutex::wxMutex()
45{
46 p_internal = new wxMutexInternal;
47 // TODO: create internal mutext handle
48 m_locked = 0;
49}
50
51wxMutex::~wxMutex()
52{
53 if (m_locked > 0)
54 wxDebugMsg("wxMutex warning: freeing a locked mutex (%d locks)\n", m_locked);
55 // TODO: free internal mutext handle
56}
57
58wxMutexError wxMutex::Lock()
59{
60 // TODO
61 m_locked++;
62 return wxMUTEX_NO_ERROR;
63}
64
65wxMutexError wxMutex::TryLock()
66{
67 // TODO
68 m_locked++;
69 return wxMUTEX_NO_ERROR;
70}
71
72wxMutexError wxMutex::Unlock()
73{
74 if (m_locked > 0)
75 m_locked--;
76
77 // TODO
78 return wxMUTEX_NO_ERROR;
79}
80
81class wxConditionInternal {
82public:
83 // TODO: internal handle
84 int waiters;
85};
86
87wxCondition::wxCondition()
88{
89 p_internal = new wxConditionInternal;
90 // TODO: create internal handle
91 p_internal->waiters = 0;
92}
93
94wxCondition::~wxCondition()
95{
96 // TODO: destroy internal handle
97}
98
99void wxCondition::Wait(wxMutex& mutex)
100{
101 mutex.Unlock();
102 p_internal->waiters++;
103 // TODO wait here
104 p_internal->waiters--;
105 mutex.Lock();
106}
107
108bool wxCondition::Wait(wxMutex& mutex, unsigned long sec,
109 unsigned long nsec)
110{
111 mutex.Unlock();
112 p_internal->waiters++;
113
114 // TODO wait here
115 p_internal->waiters--;
116 mutex.Lock();
117
118 return FALSE;
119}
120
121void wxCondition::Signal()
122{
123 // TODO
124}
125
126void wxCondition::Broadcast()
127{
128 // TODO
129}
130
131class wxThreadInternal {
132public:
133 // TODO
134};
135
136wxThreadError wxThread::Create()
137{
138 // TODO
139 return wxTHREAD_NO_ERROR;
140}
141
142wxThreadError wxThread::Destroy()
143{
144 // TODO
145 return wxTHREAD_NO_ERROR;
146}
147
148wxThreadError wxThread::Pause()
149{
150 // TODO
151 return wxTHREAD_NO_ERROR;
152}
153
154wxThreadError wxThread::Resume()
155{
156 // TODO
157 return wxTHREAD_NO_ERROR;
158}
159
160void wxThread::Exit(void *status)
161{
162 // TODO
163}
164
165void wxThread::SetPriority(int prio)
166{
167 // TODO
168}
169
170int wxThread::GetPriority() const
171{
172 // TODO
173 return 0;
174}
175
176void wxThread::DeferDestroy(bool on)
177{
178 // TODO
179}
180
181void wxThread::TestDestroy()
182{
183 // TODO
184}
185
186void *wxThread::Join()
187{
188 // TODO
189 return (void*) NULL;
190}
191
192unsigned long wxThread::GetID() const
193{
194 // TODO
195 return 0;
196}
197
198/* is this needed somewhere ?
199wxThread *wxThread::GetThreadFromID(unsigned long id)
200{
201 // TODO
202 return NULL;
203}
204*/
205
206bool wxThread::IsAlive() const
207{
208 // TODO
209 return FALSE;
210}
211
212bool wxThread::IsRunning() const
213{
214 // TODO
215 return FALSE;
216}
217
218bool wxThread::IsMain()
219{
220 // TODO
221 return FALSE;
222}
223
224wxThread::wxThread()
225{
226 p_internal = new wxThreadInternal();
227
228 // TODO
229}
230
231wxThread::~wxThread()
232{
233 Destroy();
234 Join();
235 delete p_internal;
236}
237
238// The default callback just joins the thread and throws away the result.
239void wxThread::OnExit()
240{
241 Join();
242}
243
244// Automatic initialization
245class wxThreadModule : public wxModule {
246 DECLARE_DYNAMIC_CLASS(wxThreadModule)
247public:
248 virtual bool OnInit() {
249 /* TODO p_mainid = GetCurrentThread(); */
250 wxMainMutex = new wxMutex();
251 wxMainMutex->Lock();
252 return TRUE;
253 }
254
255 // Global cleanup
256 virtual void OnExit() {
257 wxMainMutex->Unlock();
258 delete wxMainMutex;
259 }
260};
261
262IMPLEMENT_DYNAMIC_CLASS(wxThreadModule, wxModule)
263
169935ad 264#endif