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