]> git.saurik.com Git - wxWidgets.git/blob - src/gtk/threadno.cpp
cleanup - reformat
[wxWidgets.git] / src / gtk / threadno.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: thread.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 #include "wx/wx.h"
17 #include "wx/module.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)", m_locked );
29 }
30
31 wxMutexError wxMutex::Lock()
32 {
33 m_locked++;
34 return wxMUTEX_NO_ERROR;
35 }
36
37 wxMutexError wxMutex::TryLock()
38 {
39 if (m_locked > 0)
40 return wxMUTEX_BUSY;
41 m_locked++;
42 return wxMUTEX_NO_ERROR;
43 }
44
45 wxMutexError wxMutex::Unlock()
46 {
47 if (m_locked == 0)
48 return wxMUTEX_UNLOCKED;
49 m_locked--;
50 return wxMUTEX_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 {
81 int thread_id;
82 void* exit_status;
83 };
84
85 wxThreadError wxThread::Create()
86 {
87 p_internal->exit_status = Entry();
88 OnExit();
89 return wxTHREAD_NO_ERROR;
90 }
91
92 wxThreadError wxThread::Destroy()
93 {
94 return wxTHREAD_NOT_RUNNING;
95 }
96
97 wxThreadError wxThread::Pause()
98 {
99 return wxTHREAD_NOT_RUNNING;
100 }
101
102 wxThreadError wxThread::Resume()
103 {
104 return wxTHREAD_NOT_RUNNING;
105 }
106
107 void wxThread::DeferDestroy( bool WXUNUSED(on) )
108 {
109 }
110
111 void wxThread::TestDestroy()
112 {
113 }
114
115 void *wxThread::Join()
116 {
117 return p_internal->exit_status;
118 }
119
120 unsigned long wxThread::GetID() const
121 {
122 return 0;
123 }
124
125 bool wxThread::IsMain()
126 {
127 return TRUE;
128 }
129
130 bool wxThread::IsRunning() const
131 {
132 return FALSE;
133 }
134
135 bool wxThread::IsAlive() const
136 {
137 return FALSE;
138 }
139
140 void wxThread::SetPriority(int WXUNUSED(prio)) { }
141 int wxThread::GetPriority() const { return 0; }
142
143 wxMutex *wxMainMutex; // controls access to all GUI functions
144
145 wxThread::wxThread()
146 {
147 p_internal = new wxThreadInternal();
148 }
149
150 wxThread::~wxThread()
151 {
152 Destroy();
153 Join();
154 delete p_internal;
155 }
156
157 // The default callback just joins the thread and throws away the result.
158 void wxThread::OnExit()
159 {
160 Join();
161 }
162
163 IMPLEMENT_DYNAMIC_CLASS(wxThreadModule, wxModule)
164
165 bool wxThreadModule::OnInit()
166 {
167 wxMainMutex = new wxMutex();
168 wxMainMutex->Lock();
169 return TRUE;
170 }
171
172 void wxThreadModule::OnExit()
173 {
174 wxMainMutex->Unlock();
175 delete wxMainMutex;
176 }
177
178
179
180 void wxMutexGuiEnter()
181 {
182 }
183
184 void wxMutexGuiLeave()
185 {
186 }