]>
Commit | Line | Data |
---|---|---|
7c351dad GL |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: thread.cpp | |
926c550d GL |
3 | // Purpose: Solaris thread support |
4 | // Author: Guilhem Lavaux | |
7c351dad GL |
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" | |
c0392997 | 16 | #include "wx/module.h" |
8d31c138 | 17 | #include "wx/thread.h" |
3069ac4e | 18 | #include "wx/log.h" |
7c351dad | 19 | |
ee4f8c2a | 20 | wxMutex::wxMutex() |
7c351dad | 21 | { |
b89156b5 | 22 | m_locked = 0; |
7c351dad GL |
23 | } |
24 | ||
ee4f8c2a | 25 | wxMutex::~wxMutex() |
7c351dad | 26 | { |
b89156b5 | 27 | if (m_locked) |
3069ac4e | 28 | wxLogDebug( "wxMutex warning: destroying a locked mutex (%d locks)\n", m_locked ); |
7c351dad GL |
29 | } |
30 | ||
c0392997 | 31 | wxMutexError wxMutex::Lock() |
7c351dad | 32 | { |
b89156b5 | 33 | m_locked++; |
c5f885c0 | 34 | return wxMUTEX_NO_ERROR; |
7c351dad GL |
35 | } |
36 | ||
c0392997 | 37 | wxMutexError wxMutex::TryLock() |
7c351dad | 38 | { |
b89156b5 | 39 | if (m_locked > 0) |
c5f885c0 | 40 | return wxMUTEX_BUSY; |
b89156b5 | 41 | m_locked++; |
c5f885c0 | 42 | return wxMUTEX_NO_ERROR; |
7c351dad GL |
43 | } |
44 | ||
c0392997 | 45 | wxMutexError wxMutex::Unlock() |
7c351dad | 46 | { |
b89156b5 | 47 | if (m_locked == 0) |
c5f885c0 | 48 | return wxMUTEX_UNLOCKED; |
b89156b5 | 49 | m_locked--; |
c5f885c0 | 50 | return wxMUTEX_NO_ERROR; |
7c351dad GL |
51 | } |
52 | ||
ee4f8c2a | 53 | wxCondition::wxCondition() |
7c351dad GL |
54 | { |
55 | } | |
56 | ||
ee4f8c2a | 57 | wxCondition::~wxCondition() |
7c351dad GL |
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 | ||
ee4f8c2a | 71 | void wxCondition::Signal() |
7c351dad GL |
72 | { |
73 | } | |
74 | ||
ee4f8c2a | 75 | void wxCondition::Broadcast() |
7c351dad GL |
76 | { |
77 | } | |
78 | ||
c0392997 | 79 | struct wxThreadInternal { |
7c351dad GL |
80 | int thread_id; |
81 | void* exit_status; | |
82 | }; | |
83 | ||
c0392997 | 84 | wxThreadError wxThread::Create() |
7c351dad GL |
85 | { |
86 | p_internal->exit_status = Entry(); | |
87 | OnExit(); | |
c5f885c0 | 88 | return wxTHREAD_NO_ERROR; |
7c351dad GL |
89 | } |
90 | ||
c0392997 | 91 | wxThreadError wxThread::Destroy() |
7c351dad | 92 | { |
c5f885c0 | 93 | return wxTHREAD_NOT_RUNNING; |
c2dd8380 GL |
94 | } |
95 | ||
96 | wxThreadError wxThread::Pause() | |
97 | { | |
c5f885c0 | 98 | return wxTHREAD_NOT_RUNNING; |
c2dd8380 GL |
99 | } |
100 | ||
101 | wxThreadError wxThread::Resume() | |
102 | { | |
c5f885c0 | 103 | return wxTHREAD_NOT_RUNNING; |
7c351dad GL |
104 | } |
105 | ||
c0392997 | 106 | void wxThread::DeferDestroy( bool WXUNUSED(on) ) |
7c351dad GL |
107 | { |
108 | } | |
109 | ||
ee4f8c2a | 110 | void wxThread::TestDestroy() |
7c351dad GL |
111 | { |
112 | } | |
113 | ||
114 | void *wxThread::Join() | |
115 | { | |
116 | return p_internal->exit_status; | |
117 | } | |
118 | ||
ee4f8c2a | 119 | unsigned long wxThread::GetID() const |
7c351dad GL |
120 | { |
121 | return 0; | |
122 | } | |
123 | ||
ee4f8c2a | 124 | bool wxThread::IsMain() |
7c351dad GL |
125 | { |
126 | return TRUE; | |
127 | } | |
128 | ||
c2dd8380 GL |
129 | bool wxThread::IsRunning() const |
130 | { | |
131 | return FALSE; | |
132 | } | |
133 | ||
ee4f8c2a | 134 | bool wxThread::IsAlive() const |
7c351dad GL |
135 | { |
136 | return FALSE; | |
137 | } | |
138 | ||
139 | void wxThread::SetPriority(int WXUNUSED(prio)) { } | |
c0392997 | 140 | int wxThread::GetPriority() const { return 0; } |
7c351dad | 141 | |
6773ae19 | 142 | wxMutex *wxMainMutex; // controls access to all GUI functions |
7c351dad GL |
143 | |
144 | wxThread::wxThread() | |
145 | { | |
c0392997 | 146 | p_internal = new wxThreadInternal(); |
7c351dad GL |
147 | } |
148 | ||
149 | wxThread::~wxThread() | |
150 | { | |
c0392997 | 151 | Destroy(); |
7c351dad GL |
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 | ||
b89156b5 | 162 | |
d524867f | 163 | IMPLEMENT_DYNAMIC_CLASS(wxThreadModule, wxModule) |
b89156b5 | 164 | |
d524867f RR |
165 | bool wxThreadModule::OnInit() |
166 | { | |
6773ae19 GL |
167 | wxMainMutex = new wxMutex(); |
168 | wxMainMutex->Lock(); | |
b89156b5 | 169 | return TRUE; |
7c351dad GL |
170 | } |
171 | ||
c0392997 | 172 | void wxThreadModule::OnExit() |
7c351dad | 173 | { |
6773ae19 GL |
174 | wxMainMutex->Unlock(); |
175 | delete wxMainMutex; | |
7c351dad GL |
176 | } |
177 | ||
d524867f | 178 | |
c5f885c0 VZ |
179 | |
180 | void wxMutexGuiEnter() | |
181 | { | |
182 | } | |
183 | ||
184 | void wxMutexGuiLeave() | |
185 | { | |
186 | } |