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