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