]> git.saurik.com Git - wxWidgets.git/blame - src/gtk/threadno.cpp
GTK2: gtk_widget_set_uposition -> gtk_window_move for wxMiniFrame. No, I don't like...
[wxWidgets.git] / src / gtk / 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)
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 20wxMutex::wxMutex()
7c351dad 21{
518b5d2f 22 m_locked = 0;
7c351dad
GL
23}
24
ee4f8c2a 25wxMutex::~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 31wxMutexError wxMutex::Lock()
7c351dad 32{
518b5d2f
VZ
33 m_locked++;
34 return wxMUTEX_NO_ERROR;
7c351dad
GL
35}
36
c0392997 37wxMutexError 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 45wxMutexError 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 53wxCondition::wxCondition()
7c351dad
GL
54{
55}
56
ee4f8c2a 57wxCondition::~wxCondition()
7c351dad
GL
58{
59}
60
61void wxCondition::Wait(wxMutex& WXUNUSED(mutex))
62{
63}
64
65bool 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 71void wxCondition::Signal()
7c351dad
GL
72{
73}
74
ee4f8c2a 75void wxCondition::Broadcast()
7c351dad
GL
76{
77}
78
518b5d2f
VZ
79struct wxThreadInternal
80{
81 int thread_id;
82 void* exit_status;
7c351dad
GL
83};
84
c0392997 85wxThreadError wxThread::Create()
7c351dad 86{
518b5d2f
VZ
87 p_internal->exit_status = Entry();
88 OnExit();
89 return wxTHREAD_NO_ERROR;
7c351dad
GL
90}
91
c0392997 92wxThreadError wxThread::Destroy()
7c351dad 93{
518b5d2f 94 return wxTHREAD_NOT_RUNNING;
c2dd8380
GL
95}
96
97wxThreadError wxThread::Pause()
98{
518b5d2f 99 return wxTHREAD_NOT_RUNNING;
c2dd8380
GL
100}
101
102wxThreadError wxThread::Resume()
103{
518b5d2f 104 return wxTHREAD_NOT_RUNNING;
7c351dad
GL
105}
106
c0392997 107void wxThread::DeferDestroy( bool WXUNUSED(on) )
7c351dad
GL
108{
109}
110
ee4f8c2a 111void wxThread::TestDestroy()
7c351dad
GL
112{
113}
114
115void *wxThread::Join()
116{
518b5d2f 117 return p_internal->exit_status;
7c351dad
GL
118}
119
ee4f8c2a 120unsigned long wxThread::GetID() const
7c351dad 121{
518b5d2f 122 return 0;
7c351dad
GL
123}
124
ee4f8c2a 125bool wxThread::IsMain()
7c351dad 126{
518b5d2f 127 return TRUE;
7c351dad
GL
128}
129
c2dd8380
GL
130bool wxThread::IsRunning() const
131{
518b5d2f 132 return FALSE;
c2dd8380
GL
133}
134
ee4f8c2a 135bool wxThread::IsAlive() const
7c351dad 136{
518b5d2f 137 return FALSE;
7c351dad
GL
138}
139
140void wxThread::SetPriority(int WXUNUSED(prio)) { }
c0392997 141int wxThread::GetPriority() const { return 0; }
7c351dad 142
6773ae19 143wxMutex *wxMainMutex; // controls access to all GUI functions
7c351dad
GL
144
145wxThread::wxThread()
146{
518b5d2f 147 p_internal = new wxThreadInternal();
7c351dad
GL
148}
149
150wxThread::~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.
158void wxThread::OnExit()
159{
518b5d2f 160 Join();
7c351dad
GL
161}
162
d524867f 163IMPLEMENT_DYNAMIC_CLASS(wxThreadModule, wxModule)
b89156b5 164
518b5d2f 165bool wxThreadModule::OnInit()
d524867f 166{
518b5d2f
VZ
167 wxMainMutex = new wxMutex();
168 wxMainMutex->Lock();
169 return TRUE;
7c351dad
GL
170}
171
c0392997 172void wxThreadModule::OnExit()
7c351dad 173{
518b5d2f
VZ
174 wxMainMutex->Unlock();
175 delete wxMainMutex;
7c351dad
GL
176}
177
d524867f 178
c5f885c0
VZ
179
180void wxMutexGuiEnter()
181{
182}
183
184void wxMutexGuiLeave()
185{
186}