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