]> git.saurik.com Git - wxWidgets.git/blame - src/stubs/thread.cpp
Rotated text patch from Hans-Joachim Baader (with some corrections)
[wxWidgets.git] / src / stubs / thread.cpp
CommitLineData
93cf77c0
JS
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"
34138703 18#include "wx/utils.h"
93cf77c0 19
ad813b00
JS
20#if wxUSE_THREADS
21
93cf77c0
JS
22enum thread_state {
23 STATE_IDLE = 0,
24 STATE_RUNNING,
25 STATE_CANCELED,
26 STATE_EXITED
27};
28
29/////////////////////////////////////////////////////////////////////////////
30// Static variables
31/////////////////////////////////////////////////////////////////////////////
32
6773ae19 33wxMutex *wxMainMutex; // controls access to all GUI functions
93cf77c0
JS
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++;
88150e60 62 return wxMUTEX_NO_ERROR;
93cf77c0
JS
63}
64
65wxMutexError wxMutex::TryLock()
66{
67 // TODO
68 m_locked++;
88150e60 69 return wxMUTEX_NO_ERROR;
93cf77c0
JS
70}
71
72wxMutexError wxMutex::Unlock()
73{
74 if (m_locked > 0)
75 m_locked--;
76
77 // TODO
88150e60 78 return wxMUTEX_NO_ERROR;
93cf77c0
JS
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
88150e60 139 return wxTHREAD_NO_ERROR;
93cf77c0
JS
140}
141
142wxThreadError wxThread::Destroy()
143{
144 // TODO
88150e60 145 return wxTHREAD_NO_ERROR;
93cf77c0
JS
146}
147
c2dd8380
GL
148wxThreadError wxThread::Pause()
149{
150 // TODO
88150e60 151 return wxTHREAD_NO_ERROR;
c2dd8380
GL
152}
153
154wxThreadError wxThread::Resume()
155{
156 // TODO
88150e60 157 return wxTHREAD_NO_ERROR;
c2dd8380
GL
158}
159
93cf77c0
JS
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
88150e60 198/*
c2dd8380
GL
199wxThread *wxThread::GetThreadFromID(unsigned long id)
200{
201 // TODO
202 return NULL;
203}
88150e60 204*/
c2dd8380
GL
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
93cf77c0
JS
218bool wxThread::IsMain()
219{
220 // TODO
34138703 221 return FALSE;
93cf77c0
JS
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(); */
6773ae19
GL
250 wxMainMutex = new wxMutex();
251 wxMainMutex->Lock();
93cf77c0
JS
252 return TRUE;
253 }
254
255 // Global cleanup
256 virtual void OnExit() {
6773ae19
GL
257 wxMainMutex->Unlock();
258 delete wxMainMutex;
93cf77c0
JS
259 }
260};
261
262IMPLEMENT_DYNAMIC_CLASS(wxThreadModule, wxModule)
263
ad813b00
JS
264#endif
265 // wxUSE_THREADS