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