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