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