]>
Commit | Line | Data |
---|---|---|
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 | ||
17 | wxMutex::wxMutex(void) | |
18 | { | |
19 | m_locked = FALSE; | |
20 | } | |
21 | ||
22 | wxMutex::~wxMutex(void) | |
23 | { | |
24 | } | |
25 | ||
26 | MutexError wxMutex::Lock(void) | |
27 | { | |
28 | m_locked = TRUE; | |
29 | return NO_ERROR; | |
30 | } | |
31 | ||
32 | MutexError wxMutex::TryLock(void) | |
33 | { | |
34 | m_locked = TRUE; | |
35 | return NO_ERROR; | |
36 | } | |
37 | ||
38 | MutexError wxMutex::Unlock(void) | |
39 | { | |
40 | m_locked = FALSE; | |
41 | return NO_ERROR; | |
42 | } | |
43 | ||
44 | wxCondition::wxCondition(void) | |
45 | { | |
46 | } | |
47 | ||
48 | wxCondition::~wxCondition(void) | |
49 | { | |
50 | } | |
51 | ||
52 | void wxCondition::Wait(wxMutex& WXUNUSED(mutex)) | |
53 | { | |
54 | } | |
55 | ||
56 | bool wxCondition::Wait(wxMutex& WXUNUSED(mutex), unsigned long WXUNUSED(sec), | |
57 | unsigned long WXUNUSED(nsec)) | |
58 | { | |
59 | return FALSE; | |
60 | } | |
61 | ||
62 | void wxCondition::Signal(void) | |
63 | { | |
64 | } | |
65 | ||
66 | void wxCondition::Broadcast(void) | |
67 | { | |
68 | } | |
69 | ||
70 | struct wxThreadPrivate { | |
71 | int thread_id; | |
72 | void* exit_status; | |
73 | }; | |
74 | ||
75 | ThreadError wxThread::Create(void) | |
76 | { | |
77 | p_internal->exit_status = Entry(); | |
78 | OnExit(); | |
79 | return NO_ERROR; | |
80 | } | |
81 | ||
82 | ThreadError wxThread::Destroy(void) | |
83 | { | |
84 | return RUNNING; | |
85 | } | |
86 | ||
87 | void wxThread::DifferDestroy(void) | |
88 | { | |
89 | } | |
90 | ||
91 | void wxThread::TestDestroy(void) | |
92 | { | |
93 | } | |
94 | ||
95 | void *wxThread::Join() | |
96 | { | |
97 | return p_internal->exit_status; | |
98 | } | |
99 | ||
100 | unsigned long wxThread::GetID() | |
101 | { | |
102 | return 0; | |
103 | } | |
104 | ||
105 | bool wxThread::IsMain(void) | |
106 | { | |
107 | return TRUE; | |
108 | } | |
109 | ||
110 | bool wxThread::IsAlive(void) | |
111 | { | |
112 | return FALSE; | |
113 | } | |
114 | ||
115 | void wxThread::SetPriority(int WXUNUSED(prio)) { } | |
116 | int wxThread::GetPriority(void) { } | |
117 | ||
118 | wxMutex wxMainMutex; // controls access to all GUI functions | |
119 | ||
120 | wxThread::wxThread() | |
121 | { | |
122 | p_internal = new wxThreadPrivate(); | |
123 | } | |
124 | ||
125 | wxThread::~wxThread() | |
126 | { | |
127 | Cancel(); | |
128 | Join(); | |
129 | delete p_internal; | |
130 | } | |
131 | ||
132 | // The default callback just joins the thread and throws away the result. | |
133 | void wxThread::OnExit() | |
134 | { | |
135 | Join(); | |
136 | } | |
137 | ||
138 | // Global initialization | |
139 | static void wxThreadInit(void *WXUNUSED(client)) | |
140 | { | |
141 | wxMainMutex.Lock(); | |
142 | } | |
143 | ||
144 | // Global cleanup | |
145 | static void wxThreadExit(void *WXUNUSED(client)) | |
146 | { | |
147 | wxMainMutex.Unlock(); | |
148 | } | |
149 | ||
150 | // Let automatic initialization be performed from wxCommonInit(). | |
151 | static struct | |
152 | wxThreadGlobal { | |
153 | wxThreadGlobal() { | |
154 | wxRegisterModuleFunction(wxThreadInit, wxThreadExit, NULL); | |
155 | } | |
156 | } dummy; |