direct ie non mutex crit-section implementation

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@27690 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Csomor
2004-06-08 14:48:10 +00:00
parent eabc6e3cd6
commit 02f463e9cc
2 changed files with 29 additions and 3 deletions

View File

@@ -209,7 +209,7 @@ private:
// in order to avoid any overhead under platforms where critical sections are // in order to avoid any overhead under platforms where critical sections are
// just mutexes make all wxCriticalSection class functions inline // just mutexes make all wxCriticalSection class functions inline
#if !defined(__WXMSW__) #if !defined(__WXMSW__) && !defined(__WXMAC__)
#define wxCRITSECT_IS_MUTEX 1 #define wxCRITSECT_IS_MUTEX 1
#define wxCRITSECT_INLINE inline #define wxCRITSECT_INLINE inline
@@ -261,6 +261,8 @@ private:
wxCritSectBuffer m_buffer; wxCritSectBuffer m_buffer;
}; };
#elif defined(__WXMAC__)
void *m_critRegion ;
#endif // Unix&OS2/Win32 #endif // Unix&OS2/Win32
DECLARE_NO_COPY_CLASS(wxCriticalSection) DECLARE_NO_COPY_CLASS(wxCriticalSection)

View File

@@ -114,16 +114,40 @@ MPCriticalRegionID gs_guiCritical = kInvalidID;
to use two indices one for each 32 bit part as the MP implementation is limited to use two indices one for each 32 bit part as the MP implementation is limited
to longs. to longs.
I have two implementations for mutexes : I have three implementations for mutexes :
version A based on a binary semaphore, problem - not reentrant, version B based version A based on a binary semaphore, problem - not reentrant, version B based
on a critical region, allows for reentrancy, performance implications not on a critical region, allows for reentrancy, performance implications not
yet tested yet tested, and third a plain pthreads implementation
The same for condition internal, one implementation by Aj Lavin and the other one The same for condition internal, one implementation by Aj Lavin and the other one
copied from the thrimpl.cpp which I assume has been more broadly tested, I've just copied from the thrimpl.cpp which I assume has been more broadly tested, I've just
replaced the interlock increment with the appropriate PPC calls replaced the interlock increment with the appropriate PPC calls
*/ */
// ----------------------------------------------------------------------------
// wxCriticalSection
// ----------------------------------------------------------------------------
wxCriticalSection::wxCriticalSection()
{
MPCreateCriticalRegion( (MPCriticalRegionID*) &m_critRegion ) ;
}
wxCriticalSection::~wxCriticalSection()
{
MPDeleteCriticalRegion( (MPCriticalRegionID) m_critRegion ) ;
}
void wxCriticalSection::Enter()
{
MPEnterCriticalRegion( (MPCriticalRegionID) m_critRegion , kDurationForever ) ;
}
void wxCriticalSection::Leave()
{
MPExitCriticalRegion((MPCriticalRegionID) m_critRegion ) ;
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxMutex implementation // wxMutex implementation
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------