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