]> git.saurik.com Git - wxWidgets.git/blame - src/gtk/threadno.cpp
correct a bug in the MSW code using wxMask
[wxWidgets.git] / src / gtk / threadno.cpp
CommitLineData
7c351dad
GL
1/////////////////////////////////////////////////////////////////////////////
2// Name: thread.cpp
3// Purpose: No thread support
4// Author: Original from Wolfram Gloger/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#ifdef __GNUG__
12#pragma implementation "thread.h"
13#endif
14
15#include "wx/wx.h"
c0392997 16#include "wx/module.h"
8d31c138 17#include "wx/thread.h"
3069ac4e 18#include "wx/log.h"
7c351dad 19
ee4f8c2a 20wxMutex::wxMutex()
7c351dad 21{
b89156b5 22 m_locked = 0;
7c351dad
GL
23}
24
ee4f8c2a 25wxMutex::~wxMutex()
7c351dad 26{
b89156b5 27 if (m_locked)
3069ac4e 28 wxLogDebug( "wxMutex warning: destroying a locked mutex (%d locks)\n", m_locked );
7c351dad
GL
29}
30
c0392997 31wxMutexError wxMutex::Lock()
7c351dad 32{
b89156b5
GL
33 m_locked++;
34 return MUTEX_NO_ERROR;
7c351dad
GL
35}
36
c0392997 37wxMutexError wxMutex::TryLock()
7c351dad 38{
b89156b5
GL
39 if (m_locked > 0)
40 return MUTEX_BUSY;
41 m_locked++;
42 return MUTEX_NO_ERROR;
7c351dad
GL
43}
44
c0392997 45wxMutexError wxMutex::Unlock()
7c351dad 46{
b89156b5
GL
47 if (m_locked == 0)
48 return MUTEX_UNLOCKED;
49 m_locked--;
50 return MUTEX_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),
66 unsigned long WXUNUSED(nsec))
67{
68 return FALSE;
69}
70
ee4f8c2a 71void wxCondition::Signal()
7c351dad
GL
72{
73}
74
ee4f8c2a 75void wxCondition::Broadcast()
7c351dad
GL
76{
77}
78
c0392997 79struct wxThreadInternal {
7c351dad
GL
80 int thread_id;
81 void* exit_status;
82};
83
c0392997 84wxThreadError wxThread::Create()
7c351dad
GL
85{
86 p_internal->exit_status = Entry();
87 OnExit();
b89156b5 88 return THREAD_NO_ERROR;
7c351dad
GL
89}
90
c0392997 91wxThreadError wxThread::Destroy()
7c351dad 92{
c2dd8380
GL
93 return THREAD_NOT_RUNNING;
94}
95
96wxThreadError wxThread::Pause()
97{
98 return THREAD_NOT_RUNNING;
99}
100
101wxThreadError wxThread::Resume()
102{
103 return THREAD_NOT_RUNNING;
7c351dad
GL
104}
105
c0392997 106void wxThread::DeferDestroy( bool WXUNUSED(on) )
7c351dad
GL
107{
108}
109
ee4f8c2a 110void wxThread::TestDestroy()
7c351dad
GL
111{
112}
113
114void *wxThread::Join()
115{
116 return p_internal->exit_status;
117}
118
ee4f8c2a 119unsigned long wxThread::GetID() const
7c351dad
GL
120{
121 return 0;
122}
123
ee4f8c2a 124bool wxThread::IsMain()
7c351dad
GL
125{
126 return TRUE;
127}
128
c2dd8380
GL
129bool wxThread::IsRunning() const
130{
131 return FALSE;
132}
133
ee4f8c2a 134bool wxThread::IsAlive() const
7c351dad
GL
135{
136 return FALSE;
137}
138
139void wxThread::SetPriority(int WXUNUSED(prio)) { }
c0392997 140int wxThread::GetPriority() const { return 0; }
7c351dad 141
6773ae19 142wxMutex *wxMainMutex; // controls access to all GUI functions
7c351dad
GL
143
144wxThread::wxThread()
145{
c0392997 146 p_internal = new wxThreadInternal();
7c351dad
GL
147}
148
149wxThread::~wxThread()
150{
c0392997 151 Destroy();
7c351dad
GL
152 Join();
153 delete p_internal;
154}
155
156// The default callback just joins the thread and throws away the result.
157void wxThread::OnExit()
158{
159 Join();
160}
161
b89156b5
GL
162
163// Automatic initialization
164class wxThreadModule : public wxModule {
165 DECLARE_DYNAMIC_CLASS(wxThreadModule)
166public:
167 bool OnInit();
168 void OnExit();
169};
170
171bool wxThreadModule::OnInit() {
6773ae19
GL
172 wxMainMutex = new wxMutex();
173 wxMainMutex->Lock();
b89156b5 174 return TRUE;
7c351dad
GL
175}
176
c0392997 177void wxThreadModule::OnExit()
7c351dad 178{
6773ae19
GL
179 wxMainMutex->Unlock();
180 delete wxMainMutex;
7c351dad
GL
181}
182
b89156b5 183IMPLEMENT_DYNAMIC_CLASS(wxThreadModule, wxModule)