]> git.saurik.com Git - wxWidgets.git/blame - src/stubs/thread.cpp
added an error message if a bitmap can't be addedto the image list
[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
JS
19
20enum thread_state {
21 STATE_IDLE = 0,
22 STATE_RUNNING,
23 STATE_CANCELED,
24 STATE_EXITED
25};
26
27/////////////////////////////////////////////////////////////////////////////
28// Static variables
29/////////////////////////////////////////////////////////////////////////////
30
6773ae19 31wxMutex *wxMainMutex; // controls access to all GUI functions
93cf77c0
JS
32
33/////////////////////////////////////////////////////////////////////////////
34// Windows implementation
35/////////////////////////////////////////////////////////////////////////////
36
37class wxMutexInternal {
38public:
39 // TODO: internal mutex handle
40};
41
42wxMutex::wxMutex()
43{
44 p_internal = new wxMutexInternal;
45 // TODO: create internal mutext handle
46 m_locked = 0;
47}
48
49wxMutex::~wxMutex()
50{
51 if (m_locked > 0)
52 wxDebugMsg("wxMutex warning: freeing a locked mutex (%d locks)\n", m_locked);
53 // TODO: free internal mutext handle
54}
55
56wxMutexError wxMutex::Lock()
57{
58 // TODO
59 m_locked++;
88150e60 60 return wxMUTEX_NO_ERROR;
93cf77c0
JS
61}
62
63wxMutexError wxMutex::TryLock()
64{
65 // TODO
66 m_locked++;
88150e60 67 return wxMUTEX_NO_ERROR;
93cf77c0
JS
68}
69
70wxMutexError wxMutex::Unlock()
71{
72 if (m_locked > 0)
73 m_locked--;
74
75 // TODO
88150e60 76 return wxMUTEX_NO_ERROR;
93cf77c0
JS
77}
78
79class wxConditionInternal {
80public:
81 // TODO: internal handle
82 int waiters;
83};
84
85wxCondition::wxCondition()
86{
87 p_internal = new wxConditionInternal;
88 // TODO: create internal handle
89 p_internal->waiters = 0;
90}
91
92wxCondition::~wxCondition()
93{
94 // TODO: destroy internal handle
95}
96
97void wxCondition::Wait(wxMutex& mutex)
98{
99 mutex.Unlock();
100 p_internal->waiters++;
101 // TODO wait here
102 p_internal->waiters--;
103 mutex.Lock();
104}
105
106bool wxCondition::Wait(wxMutex& mutex, unsigned long sec,
107 unsigned long nsec)
108{
109 mutex.Unlock();
110 p_internal->waiters++;
111
112 // TODO wait here
113 p_internal->waiters--;
114 mutex.Lock();
115
116 return FALSE;
117}
118
119void wxCondition::Signal()
120{
121 // TODO
122}
123
124void wxCondition::Broadcast()
125{
126 // TODO
127}
128
129class wxThreadInternal {
130public:
131 // TODO
132};
133
134wxThreadError wxThread::Create()
135{
136 // TODO
88150e60 137 return wxTHREAD_NO_ERROR;
93cf77c0
JS
138}
139
140wxThreadError wxThread::Destroy()
141{
142 // TODO
88150e60 143 return wxTHREAD_NO_ERROR;
93cf77c0
JS
144}
145
c2dd8380
GL
146wxThreadError wxThread::Pause()
147{
148 // TODO
88150e60 149 return wxTHREAD_NO_ERROR;
c2dd8380
GL
150}
151
152wxThreadError wxThread::Resume()
153{
154 // TODO
88150e60 155 return wxTHREAD_NO_ERROR;
c2dd8380
GL
156}
157
93cf77c0
JS
158void wxThread::Exit(void *status)
159{
160 // TODO
161}
162
163void wxThread::SetPriority(int prio)
164{
165 // TODO
166}
167
168int wxThread::GetPriority() const
169{
170 // TODO
171 return 0;
172}
173
174void wxThread::DeferDestroy(bool on)
175{
176 // TODO
177}
178
179void wxThread::TestDestroy()
180{
181 // TODO
182}
183
184void *wxThread::Join()
185{
186 // TODO
187 return (void*) NULL;
188}
189
190unsigned long wxThread::GetID() const
191{
192 // TODO
193 return 0;
194}
195
88150e60 196/*
c2dd8380
GL
197wxThread *wxThread::GetThreadFromID(unsigned long id)
198{
199 // TODO
200 return NULL;
201}
88150e60 202*/
c2dd8380
GL
203
204bool wxThread::IsAlive() const
205{
206 // TODO
207 return FALSE;
208}
209
210bool wxThread::IsRunning() const
211{
212 // TODO
213 return FALSE;
214}
215
93cf77c0
JS
216bool wxThread::IsMain()
217{
218 // TODO
34138703 219 return FALSE;
93cf77c0
JS
220}
221
222wxThread::wxThread()
223{
224 p_internal = new wxThreadInternal();
225
226 // TODO
227}
228
229wxThread::~wxThread()
230{
231 Destroy();
232 Join();
233 delete p_internal;
234}
235
236// The default callback just joins the thread and throws away the result.
237void wxThread::OnExit()
238{
239 Join();
240}
241
242// Automatic initialization
243class wxThreadModule : public wxModule {
244 DECLARE_DYNAMIC_CLASS(wxThreadModule)
245public:
246 virtual bool OnInit() {
247 /* TODO p_mainid = GetCurrentThread(); */
6773ae19
GL
248 wxMainMutex = new wxMutex();
249 wxMainMutex->Lock();
93cf77c0
JS
250 return TRUE;
251 }
252
253 // Global cleanup
254 virtual void OnExit() {
6773ae19
GL
255 wxMainMutex->Unlock();
256 delete wxMainMutex;
93cf77c0
JS
257 }
258};
259
260IMPLEMENT_DYNAMIC_CLASS(wxThreadModule, wxModule)
261