]> git.saurik.com Git - wxWidgets.git/blame - src/qt/threadno.cpp
fixed the vsprintf() problem once and for all
[wxWidgets.git] / src / qt / threadno.cpp
CommitLineData
7c78e7c7
RR
1/////////////////////////////////////////////////////////////////////////////
2// Name: thread.cpp
3// Purpose: No thread support
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#ifdef __GNUG__
12#pragma implementation "thread.h"
13#endif
14
15#include "wx/wx.h"
16#include "wx/module.h"
17#include "wx/thread.h"
18
19wxMutex::wxMutex()
20{
21 m_locked = 0;
22}
23
24wxMutex::~wxMutex()
25{
26 if (m_locked)
27 wxDebugMsg("wxMutex warning: destroying a locked mutex (%d locks)\n", m_locked);
28}
29
30wxMutexError wxMutex::Lock()
31{
32 m_locked++;
33 return MUTEX_NO_ERROR;
34}
35
36wxMutexError wxMutex::TryLock()
37{
38 if (m_locked > 0)
39 return MUTEX_BUSY;
40 m_locked++;
41 return MUTEX_NO_ERROR;
42}
43
44wxMutexError wxMutex::Unlock()
45{
46 if (m_locked == 0)
47 return MUTEX_UNLOCKED;
48 m_locked--;
49 return MUTEX_NO_ERROR;
50}
51
52wxCondition::wxCondition()
53{
54}
55
56wxCondition::~wxCondition()
57{
58}
59
60void wxCondition::Wait(wxMutex& WXUNUSED(mutex))
61{
62}
63
64bool wxCondition::Wait(wxMutex& WXUNUSED(mutex), unsigned long WXUNUSED(sec),
65 unsigned long WXUNUSED(nsec))
66{
67 return FALSE;
68}
69
70void wxCondition::Signal()
71{
72}
73
74void wxCondition::Broadcast()
75{
76}
77
78struct wxThreadInternal {
79 int thread_id;
80 void* exit_status;
81};
82
83wxThreadError wxThread::Create()
84{
85 p_internal->exit_status = Entry();
86 OnExit();
87 return THREAD_NO_ERROR;
88}
89
90wxThreadError wxThread::Destroy()
91{
c2dd8380
GL
92 return THREAD_NOT_RUNNING;
93}
94
95wxThreadError wxThread::Pause()
96{
97 return THREAD_NOT_RUNNING;
98}
99
100wxThreadError wxThread::Resume()
101{
102 return THREAD_NOT_RUNNING;
7c78e7c7
RR
103}
104
105void wxThread::DeferDestroy( bool WXUNUSED(on) )
106{
107}
108
109void wxThread::TestDestroy()
110{
111}
112
113void *wxThread::Join()
114{
115 return p_internal->exit_status;
116}
117
118unsigned long wxThread::GetID() const
119{
120 return 0;
121}
122
c2dd8380
GL
123wxThread *wxThread::GetThreadFromID(unsigned long WXUNUSED(id)) const
124{
125 return NULL;
126}
127
7c78e7c7
RR
128bool wxThread::IsMain()
129{
130 return TRUE;
131}
132
c2dd8380
GL
133bool wxThread::IsRunning() const
134{
135 return FALSE;
136}
137
7c78e7c7
RR
138bool wxThread::IsAlive() const
139{
140 return FALSE;
141}
142
143void wxThread::SetPriority(int WXUNUSED(prio)) { }
144int wxThread::GetPriority() const { return 0; }
145
6773ae19 146wxMutex *wxMainMutex; // controls access to all GUI functions
7c78e7c7
RR
147
148wxThread::wxThread()
149{
150 p_internal = new wxThreadInternal();
151}
152
153wxThread::~wxThread()
154{
155 Destroy();
156 Join();
157 delete p_internal;
158}
159
160// The default callback just joins the thread and throws away the result.
161void wxThread::OnExit()
162{
163 Join();
164}
165
166
167// Automatic initialization
168class wxThreadModule : public wxModule {
169 DECLARE_DYNAMIC_CLASS(wxThreadModule)
170public:
171 bool OnInit();
172 void OnExit();
173};
174
175bool wxThreadModule::OnInit() {
6773ae19
GL
176 wxMainMutex = new wxMutex();
177 wxMainMutex->Lock();
7c78e7c7
RR
178 return TRUE;
179}
180
181void wxThreadModule::OnExit()
182{
6773ae19
GL
183 wxMainMutex->Unlock();
184 delete wxMainMutex;
7c78e7c7
RR
185}
186
187IMPLEMENT_DYNAMIC_CLASS(wxThreadModule, wxModule)