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