]> git.saurik.com Git - wxWidgets.git/blame - include/wx/thrimpl.cpp
warnings (and some errors) fixes for wxUniv DLL build
[wxWidgets.git] / include / wx / thrimpl.cpp
CommitLineData
9e84b847
VZ
1/////////////////////////////////////////////////////////////////////////////
2// Name: include/wx/thrimpl.cpp
3// Purpose: common part of wxThread Implementations
4// Author: Vadim Zeitlin
5// Modified by:
6// Created: 04.06.02 (extracted from src/*/thread.cpp files)
7// RCS-ID: $Id$
8// Copyright: (c) Vadim Zeitlin (2002)
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12// this file is supposed to be included only by the various thread.cpp
13
14// ----------------------------------------------------------------------------
15// wxMutex
16// ----------------------------------------------------------------------------
17
18wxMutex::wxMutex(wxMutexType mutexType)
19{
20 m_internal = new wxMutexInternal(mutexType);
21
22 if ( !m_internal->IsOk() )
23 {
24 delete m_internal;
25 m_internal = NULL;
26 }
27}
28
29wxMutex::~wxMutex()
30{
31 delete m_internal;
32}
33
34bool wxMutex::IsOk() const
35{
36 return m_internal != NULL;
37}
38
39wxMutexError wxMutex::Lock()
40{
41 wxCHECK_MSG( m_internal, wxMUTEX_INVALID,
42 _T("wxMutex::Lock(): not initialized") );
43
44 return m_internal->Lock();
45}
46
47wxMutexError wxMutex::TryLock()
48{
49 wxCHECK_MSG( m_internal, wxMUTEX_INVALID,
50 _T("wxMutex::TryLock(): not initialized") );
51
52 return m_internal->TryLock();
53}
54
55wxMutexError wxMutex::Unlock()
56{
57 wxCHECK_MSG( m_internal, wxMUTEX_INVALID,
58 _T("wxMutex::Unlock(): not initialized") );
59
60 return m_internal->Unlock();
61}
62
63// ----------------------------------------------------------------------------
64// wxCondition
65// ----------------------------------------------------------------------------
66
67wxCondition::wxCondition(wxMutex& mutex)
68{
69 m_internal = new wxConditionInternal(mutex);
70
71 if ( !m_internal->IsOk() )
72 {
73 delete m_internal;
74 m_internal = NULL;
75 }
76}
77
78wxCondition::~wxCondition()
79{
80 delete m_internal;
81}
82
83bool wxCondition::IsOk() const
84{
85 return m_internal != NULL;
86}
87
88wxCondError wxCondition::Wait()
89{
90 wxCHECK_MSG( m_internal, wxCOND_INVALID,
91 _T("wxCondition::Wait(): not initialized") );
92
93 return m_internal->Wait();
94}
95
96wxCondError wxCondition::WaitTimeout(unsigned long milliseconds)
97{
98 wxCHECK_MSG( m_internal, wxCOND_INVALID,
99 _T("wxCondition::Wait(): not initialized") );
100
101 return m_internal->WaitTimeout(milliseconds);
102}
103
104wxCondError wxCondition::Signal()
105{
106 wxCHECK_MSG( m_internal, wxCOND_INVALID,
107 _T("wxCondition::Signal(): not initialized") );
108
109 return m_internal->Signal();
110}
111
112wxCondError wxCondition::Broadcast()
113{
114 wxCHECK_MSG( m_internal, wxCOND_INVALID,
115 _T("wxCondition::Broadcast(): not initialized") );
116
117 return m_internal->Broadcast();
118}
119
120// --------------------------------------------------------------------------
121// wxSemaphore
122// --------------------------------------------------------------------------
123
124wxSemaphore::wxSemaphore(int initialcount, int maxcount)
125{
126 m_internal = new wxSemaphoreInternal( initialcount, maxcount );
127 if ( !m_internal->IsOk() )
128 {
129 delete m_internal;
130 m_internal = NULL;
131 }
132}
133
134wxSemaphore::~wxSemaphore()
135{
136 delete m_internal;
137}
138
139bool wxSemaphore::IsOk() const
140{
141 return m_internal != NULL;
142}
143
144wxSemaError wxSemaphore::Wait()
145{
146 wxCHECK_MSG( m_internal, wxSEMA_INVALID,
147 _T("wxSemaphore::Wait(): not initialized") );
148
149 return m_internal->Wait();
150}
151
152wxSemaError wxSemaphore::TryWait()
153{
154 wxCHECK_MSG( m_internal, wxSEMA_INVALID,
155 _T("wxSemaphore::TryWait(): not initialized") );
156
157 return m_internal->TryWait();
158}
159
160wxSemaError wxSemaphore::WaitTimeout(unsigned long milliseconds)
161{
162 wxCHECK_MSG( m_internal, wxSEMA_INVALID,
163 _T("wxSemaphore::WaitTimeout(): not initialized") );
164
165 return m_internal->WaitTimeout(milliseconds);
166}
167
168wxSemaError wxSemaphore::Post()
169{
170 wxCHECK_MSG( m_internal, wxSEMA_INVALID,
171 _T("wxSemaphore::Post(): not initialized") );
172
173 return m_internal->Post();
174}
175