]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/thrimpl.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: include/wx/thrimpl.cpp
3 // Purpose: common part of wxThread Implementations
4 // Author: Vadim Zeitlin
6 // Created: 04.06.02 (extracted from src/*/thread.cpp files)
8 // Copyright: (c) Vadim Zeitlin (2002)
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // this file is supposed to be included only by the various thread.cpp
14 // ----------------------------------------------------------------------------
16 // ----------------------------------------------------------------------------
18 wxMutex::wxMutex(wxMutexType mutexType
)
20 m_internal
= new wxMutexInternal(mutexType
);
22 if ( !m_internal
->IsOk() )
34 bool wxMutex::IsOk() const
36 return m_internal
!= NULL
;
39 wxMutexError
wxMutex::Lock()
41 wxCHECK_MSG( m_internal
, wxMUTEX_INVALID
,
42 _T("wxMutex::Lock(): not initialized") );
44 return m_internal
->Lock();
47 wxMutexError
wxMutex::TryLock()
49 wxCHECK_MSG( m_internal
, wxMUTEX_INVALID
,
50 _T("wxMutex::TryLock(): not initialized") );
52 return m_internal
->TryLock();
55 wxMutexError
wxMutex::Unlock()
57 wxCHECK_MSG( m_internal
, wxMUTEX_INVALID
,
58 _T("wxMutex::Unlock(): not initialized") );
60 return m_internal
->Unlock();
63 // ----------------------------------------------------------------------------
65 // ----------------------------------------------------------------------------
67 wxCondition::wxCondition(wxMutex
& mutex
)
69 m_internal
= new wxConditionInternal(mutex
);
71 if ( !m_internal
->IsOk() )
78 wxCondition::~wxCondition()
83 bool wxCondition::IsOk() const
85 return m_internal
!= NULL
;
88 wxCondError
wxCondition::Wait()
90 wxCHECK_MSG( m_internal
, wxCOND_INVALID
,
91 _T("wxCondition::Wait(): not initialized") );
93 return m_internal
->Wait();
96 wxCondError
wxCondition::WaitTimeout(unsigned long milliseconds
)
98 wxCHECK_MSG( m_internal
, wxCOND_INVALID
,
99 _T("wxCondition::Wait(): not initialized") );
101 return m_internal
->WaitTimeout(milliseconds
);
104 wxCondError
wxCondition::Signal()
106 wxCHECK_MSG( m_internal
, wxCOND_INVALID
,
107 _T("wxCondition::Signal(): not initialized") );
109 return m_internal
->Signal();
112 wxCondError
wxCondition::Broadcast()
114 wxCHECK_MSG( m_internal
, wxCOND_INVALID
,
115 _T("wxCondition::Broadcast(): not initialized") );
117 return m_internal
->Broadcast();
120 // --------------------------------------------------------------------------
122 // --------------------------------------------------------------------------
124 wxSemaphore::wxSemaphore(int initialcount
, int maxcount
)
126 m_internal
= new wxSemaphoreInternal( initialcount
, maxcount
);
127 if ( !m_internal
->IsOk() )
134 wxSemaphore::~wxSemaphore()
139 bool wxSemaphore::IsOk() const
141 return m_internal
!= NULL
;
144 wxSemaError
wxSemaphore::Wait()
146 wxCHECK_MSG( m_internal
, wxSEMA_INVALID
,
147 _T("wxSemaphore::Wait(): not initialized") );
149 return m_internal
->Wait();
152 wxSemaError
wxSemaphore::TryWait()
154 wxCHECK_MSG( m_internal
, wxSEMA_INVALID
,
155 _T("wxSemaphore::TryWait(): not initialized") );
157 return m_internal
->TryWait();
160 wxSemaError
wxSemaphore::WaitTimeout(unsigned long milliseconds
)
162 wxCHECK_MSG( m_internal
, wxSEMA_INVALID
,
163 _T("wxSemaphore::WaitTimeout(): not initialized") );
165 return m_internal
->WaitTimeout(milliseconds
);
168 wxSemaError
wxSemaphore::Post()
170 wxCHECK_MSG( m_internal
, wxSEMA_INVALID
,
171 _T("wxSemaphore::Post(): not initialized") );
173 return m_internal
->Post();