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