]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/gtk1/threadno.cpp
New wxEventType for event type enum, and corresponding alterations.
[wxWidgets.git] / src / gtk1 / threadno.cpp
... / ...
CommitLineData
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"
16#include "wx/thread.h"
17
18wxMutex::wxMutex()
19{
20 m_locked = 0;
21}
22
23wxMutex::~wxMutex()
24{
25 if (m_locked)
26 wxDebugMsg("wxMutex warning: destroying a locked mutex (%d locks)\n", m_locked);
27}
28
29MutexError wxMutex::Lock()
30{
31 m_locked++;
32 return MUTEX_NO_ERROR;
33}
34
35MutexError wxMutex::TryLock()
36{
37 if (m_locked > 0)
38 return MUTEX_BUSY;
39 m_locked++;
40 return MUTEX_NO_ERROR;
41}
42
43MutexError wxMutex::Unlock()
44{
45 if (m_locked == 0)
46 return MUTEX_UNLOCKED;
47 m_locked--;
48 return MUTEX_NO_ERROR;
49}
50
51wxCondition::wxCondition()
52{
53}
54
55wxCondition::~wxCondition()
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
69void wxCondition::Signal()
70{
71}
72
73void wxCondition::Broadcast()
74{
75}
76
77struct wxThreadPrivate {
78 int thread_id;
79 void* exit_status;
80};
81
82ThreadError wxThread::Create()
83{
84 p_internal->exit_status = Entry();
85 OnExit();
86 return THREAD_NO_ERROR;
87}
88
89ThreadError wxThread::Destroy()
90{
91 return THREAD_RUNNING;
92}
93
94void wxThread::DeferDestroy()
95{
96}
97
98void wxThread::TestDestroy()
99{
100}
101
102void *wxThread::Join()
103{
104 return p_internal->exit_status;
105}
106
107unsigned long wxThread::GetID() const
108{
109 return 0;
110}
111
112bool wxThread::IsMain()
113{
114 return TRUE;
115}
116
117bool wxThread::IsAlive() const
118{
119 return FALSE;
120}
121
122void wxThread::SetPriority(int WXUNUSED(prio)) { }
123int wxThread::GetPriority() const { }
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
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() {
155 wxMainMutex.Lock();
156 return TRUE;
157}
158
159void wxThreadModule::wxThreadExit()
160{
161 wxMainMutex.Unlock();
162}
163
164IMPLEMENT_DYNAMIC_CLASS(wxThreadModule, wxModule)