]> git.saurik.com Git - wxWidgets.git/blob - src/gtk1/threadno.cpp
'Set to Unspecified' -> 'Set Value to Unspecified'
[wxWidgets.git] / src / gtk1 / threadno.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/gtk1/threadno.cpp
3 // Purpose: Solaris thread support
4 // Author: 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 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
14
15 #include "wx/thread.h"
16
17 #ifndef WX_PRECOMP
18 #include "wx/wx.h"
19 #include "wx/log.h"
20 #include "wx/module.h"
21 #endif
22
23 wxMutex::wxMutex()
24 {
25 m_locked = 0;
26 }
27
28 wxMutex::~wxMutex()
29 {
30 if (m_locked)
31 {
32 wxLogDebug( "wxMutex warning: destroying a locked mutex (%d locks)", m_locked );
33 }
34 }
35
36 wxMutexError wxMutex::Lock()
37 {
38 m_locked++;
39 return wxMUTEX_NO_ERROR;
40 }
41
42 wxMutexError wxMutex::TryLock()
43 {
44 if (m_locked > 0)
45 return wxMUTEX_BUSY;
46 m_locked++;
47 return wxMUTEX_NO_ERROR;
48 }
49
50 wxMutexError wxMutex::Unlock()
51 {
52 if (m_locked == 0)
53 return wxMUTEX_UNLOCKED;
54 m_locked--;
55 return wxMUTEX_NO_ERROR;
56 }
57
58 wxCondition::wxCondition()
59 {
60 }
61
62 wxCondition::~wxCondition()
63 {
64 }
65
66 void wxCondition::Wait(wxMutex& WXUNUSED(mutex))
67 {
68 }
69
70 bool wxCondition::Wait(wxMutex& WXUNUSED(mutex), unsigned long WXUNUSED(sec),
71 unsigned long WXUNUSED(nsec))
72 {
73 return false;
74 }
75
76 void wxCondition::Signal()
77 {
78 }
79
80 void wxCondition::Broadcast()
81 {
82 }
83
84 struct wxThreadInternal
85 {
86 int thread_id;
87 void* exit_status;
88 };
89
90 wxThreadError wxThread::Create()
91 {
92 p_internal->exit_status = Entry();
93 OnExit();
94 return wxTHREAD_NO_ERROR;
95 }
96
97 wxThreadError wxThread::Destroy()
98 {
99 return wxTHREAD_NOT_RUNNING;
100 }
101
102 wxThreadError wxThread::Pause()
103 {
104 return wxTHREAD_NOT_RUNNING;
105 }
106
107 wxThreadError wxThread::Resume()
108 {
109 return wxTHREAD_NOT_RUNNING;
110 }
111
112 void wxThread::DeferDestroy( bool WXUNUSED(on) )
113 {
114 }
115
116 void wxThread::TestDestroy()
117 {
118 }
119
120 void *wxThread::Join()
121 {
122 return p_internal->exit_status;
123 }
124
125 unsigned long wxThread::GetID() const
126 {
127 return 0;
128 }
129
130 bool wxThread::IsMain()
131 {
132 return true;
133 }
134
135 bool wxThread::IsRunning() const
136 {
137 return false;
138 }
139
140 bool wxThread::IsAlive() const
141 {
142 return false;
143 }
144
145 void wxThread::SetPriority(int WXUNUSED(prio)) { }
146 int wxThread::GetPriority() const { return 0; }
147
148 wxMutex *wxMainMutex; // controls access to all GUI functions
149
150 wxThread::wxThread()
151 {
152 p_internal = new wxThreadInternal();
153 }
154
155 wxThread::~wxThread()
156 {
157 Destroy();
158 Join();
159 delete p_internal;
160 }
161
162 // The default callback just joins the thread and throws away the result.
163 void wxThread::OnExit()
164 {
165 Join();
166 }
167
168 IMPLEMENT_DYNAMIC_CLASS(wxThreadModule, wxModule)
169
170 bool wxThreadModule::OnInit()
171 {
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
184
185 void wxMutexGuiEnter()
186 {
187 }
188
189 void wxMutexGuiLeave()
190 {
191 }