]> git.saurik.com Git - wxWidgets.git/blame - src/gtk1/threadno.cpp
fix building with WXWIN_COMPATIBILITY_2_8 == 0
[wxWidgets.git] / src / gtk1 / threadno.cpp
CommitLineData
7c351dad 1/////////////////////////////////////////////////////////////////////////////
02761f6c 2// Name: src/gtk1/threadno.cpp
926c550d
GL
3// Purpose: Solaris thread support
4// Author: Guilhem Lavaux
7c351dad
GL
5// Modified by:
6// Created: 04/22/98
7c351dad 7// Copyright: (c) Wolfram Gloger (1996, 1997); Guilhem Lavaux (1998)
65571936 8// Licence: wxWindows licence
7c351dad 9/////////////////////////////////////////////////////////////////////////////
518b5d2f 10
14f355c2
VS
11// For compilers that support precompilation, includes "wx.h".
12#include "wx/wxprec.h"
13
e1bf3ad3 14#include "wx/thread.h"
e4db172a
WS
15
16#ifndef WX_PRECOMP
17 #include "wx/wx.h"
18 #include "wx/log.h"
02761f6c 19 #include "wx/module.h"
e4db172a
WS
20#endif
21
ee4f8c2a 22wxMutex::wxMutex()
7c351dad 23{
518b5d2f 24 m_locked = 0;
7c351dad
GL
25}
26
ee4f8c2a 27wxMutex::~wxMutex()
7c351dad 28{
518b5d2f 29 if (m_locked)
43b2d5e7 30 {
518b5d2f 31 wxLogDebug( "wxMutex warning: destroying a locked mutex (%d locks)", m_locked );
43b2d5e7 32 }
7c351dad
GL
33}
34
c0392997 35wxMutexError wxMutex::Lock()
7c351dad 36{
518b5d2f
VZ
37 m_locked++;
38 return wxMUTEX_NO_ERROR;
7c351dad
GL
39}
40
c0392997 41wxMutexError 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 49wxMutexError 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 57wxCondition::wxCondition()
7c351dad
GL
58{
59}
60
ee4f8c2a 61wxCondition::~wxCondition()
7c351dad
GL
62{
63}
64
65void wxCondition::Wait(wxMutex& WXUNUSED(mutex))
66{
67}
68
69bool wxCondition::Wait(wxMutex& WXUNUSED(mutex), unsigned long WXUNUSED(sec),
518b5d2f 70 unsigned long WXUNUSED(nsec))
7c351dad 71{
02761f6c 72 return false;
7c351dad
GL
73}
74
ee4f8c2a 75void wxCondition::Signal()
7c351dad
GL
76{
77}
78
ee4f8c2a 79void wxCondition::Broadcast()
7c351dad
GL
80{
81}
82
518b5d2f
VZ
83struct wxThreadInternal
84{
85 int thread_id;
86 void* exit_status;
7c351dad
GL
87};
88
c0392997 89wxThreadError wxThread::Create()
7c351dad 90{
518b5d2f
VZ
91 p_internal->exit_status = Entry();
92 OnExit();
93 return wxTHREAD_NO_ERROR;
7c351dad
GL
94}
95
c0392997 96wxThreadError wxThread::Destroy()
7c351dad 97{
518b5d2f 98 return wxTHREAD_NOT_RUNNING;
c2dd8380
GL
99}
100
101wxThreadError wxThread::Pause()
102{
518b5d2f 103 return wxTHREAD_NOT_RUNNING;
c2dd8380
GL
104}
105
106wxThreadError wxThread::Resume()
107{
518b5d2f 108 return wxTHREAD_NOT_RUNNING;
7c351dad
GL
109}
110
c0392997 111void wxThread::DeferDestroy( bool WXUNUSED(on) )
7c351dad
GL
112{
113}
114
ee4f8c2a 115void wxThread::TestDestroy()
7c351dad
GL
116{
117}
118
119void *wxThread::Join()
120{
518b5d2f 121 return p_internal->exit_status;
7c351dad
GL
122}
123
ee4f8c2a 124unsigned long wxThread::GetID() const
7c351dad 125{
518b5d2f 126 return 0;
7c351dad
GL
127}
128
ee4f8c2a 129bool wxThread::IsMain()
7c351dad 130{
02761f6c 131 return true;
7c351dad
GL
132}
133
c2dd8380
GL
134bool wxThread::IsRunning() const
135{
02761f6c 136 return false;
c2dd8380
GL
137}
138
ee4f8c2a 139bool wxThread::IsAlive() const
7c351dad 140{
02761f6c 141 return false;
7c351dad
GL
142}
143
144void wxThread::SetPriority(int WXUNUSED(prio)) { }
c0392997 145int wxThread::GetPriority() const { return 0; }
7c351dad 146
6773ae19 147wxMutex *wxMainMutex; // controls access to all GUI functions
7c351dad
GL
148
149wxThread::wxThread()
150{
518b5d2f 151 p_internal = new wxThreadInternal();
7c351dad
GL
152}
153
154wxThread::~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.
162void wxThread::OnExit()
163{
518b5d2f 164 Join();
7c351dad
GL
165}
166
d524867f 167IMPLEMENT_DYNAMIC_CLASS(wxThreadModule, wxModule)
b89156b5 168
518b5d2f 169bool wxThreadModule::OnInit()
d524867f 170{
518b5d2f
VZ
171 wxMainMutex = new wxMutex();
172 wxMainMutex->Lock();
02761f6c 173 return true;
7c351dad
GL
174}
175
c0392997 176void wxThreadModule::OnExit()
7c351dad 177{
518b5d2f
VZ
178 wxMainMutex->Unlock();
179 delete wxMainMutex;
7c351dad
GL
180}
181
d524867f 182
c5f885c0
VZ
183
184void wxMutexGuiEnter()
185{
186}
187
188void wxMutexGuiLeave()
189{
190}