]> git.saurik.com Git - wxWidgets.git/blame - src/gtk/threadno.cpp
bug in wxNotebook::OnSize() corrected
[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"
8d31c138 16#include "wx/thread.h"
7c351dad 17
ee4f8c2a 18wxMutex::wxMutex()
7c351dad 19{
b89156b5 20 m_locked = 0;
7c351dad
GL
21}
22
ee4f8c2a 23wxMutex::~wxMutex()
7c351dad 24{
b89156b5
GL
25 if (m_locked)
26 wxDebugMsg("wxMutex warning: destroying a locked mutex (%d locks)\n", m_locked);
7c351dad
GL
27}
28
ee4f8c2a 29MutexError wxMutex::Lock()
7c351dad 30{
b89156b5
GL
31 m_locked++;
32 return MUTEX_NO_ERROR;
7c351dad
GL
33}
34
ee4f8c2a 35MutexError wxMutex::TryLock()
7c351dad 36{
b89156b5
GL
37 if (m_locked > 0)
38 return MUTEX_BUSY;
39 m_locked++;
40 return MUTEX_NO_ERROR;
7c351dad
GL
41}
42
ee4f8c2a 43MutexError wxMutex::Unlock()
7c351dad 44{
b89156b5
GL
45 if (m_locked == 0)
46 return MUTEX_UNLOCKED;
47 m_locked--;
48 return MUTEX_NO_ERROR;
7c351dad
GL
49}
50
ee4f8c2a 51wxCondition::wxCondition()
7c351dad
GL
52{
53}
54
ee4f8c2a 55wxCondition::~wxCondition()
7c351dad
GL
56{
57}
58
59void wxCondition::Wait(wxMutex& WXUNUSED(mutex))
60{
61}
62
63bool wxCondition::Wait(wxMutex& WXUNUSED(mutex), unsigned long WXUNUSED(sec),
64 unsigned long WXUNUSED(nsec))
65{
66 return FALSE;
67}
68
ee4f8c2a 69void wxCondition::Signal()
7c351dad
GL
70{
71}
72
ee4f8c2a 73void wxCondition::Broadcast()
7c351dad
GL
74{
75}
76
77struct wxThreadPrivate {
78 int thread_id;
79 void* exit_status;
80};
81
ee4f8c2a 82ThreadError wxThread::Create()
7c351dad
GL
83{
84 p_internal->exit_status = Entry();
85 OnExit();
b89156b5 86 return THREAD_NO_ERROR;
7c351dad
GL
87}
88
ee4f8c2a 89ThreadError wxThread::Destroy()
7c351dad 90{
b89156b5 91 return THREAD_RUNNING;
7c351dad
GL
92}
93
ee4f8c2a 94void wxThread::DeferDestroy()
7c351dad
GL
95{
96}
97
ee4f8c2a 98void wxThread::TestDestroy()
7c351dad
GL
99{
100}
101
102void *wxThread::Join()
103{
104 return p_internal->exit_status;
105}
106
ee4f8c2a 107unsigned long wxThread::GetID() const
7c351dad
GL
108{
109 return 0;
110}
111
ee4f8c2a 112bool wxThread::IsMain()
7c351dad
GL
113{
114 return TRUE;
115}
116
ee4f8c2a 117bool wxThread::IsAlive() const
7c351dad
GL
118{
119 return FALSE;
120}
121
122void wxThread::SetPriority(int WXUNUSED(prio)) { }
ee4f8c2a 123int wxThread::GetPriority() const { }
7c351dad
GL
124
125wxMutex wxMainMutex; // controls access to all GUI functions
126
127wxThread::wxThread()
128{
129 p_internal = new wxThreadPrivate();
130}
131
132wxThread::~wxThread()
133{
134 Cancel();
135 Join();
136 delete p_internal;
137}
138
139// The default callback just joins the thread and throws away the result.
140void wxThread::OnExit()
141{
142 Join();
143}
144
b89156b5
GL
145
146// Automatic initialization
147class wxThreadModule : public wxModule {
148 DECLARE_DYNAMIC_CLASS(wxThreadModule)
149public:
150 bool OnInit();
151 void OnExit();
152};
153
154bool wxThreadModule::OnInit() {
7c351dad 155 wxMainMutex.Lock();
b89156b5 156 return TRUE;
7c351dad
GL
157}
158
b89156b5 159void wxThreadModule::wxThreadExit()
7c351dad
GL
160{
161 wxMainMutex.Unlock();
162}
163
b89156b5 164IMPLEMENT_DYNAMIC_CLASS(wxThreadModule, wxModule)