// need a critical section to protect access to gs_compareFunction and
// gs_sortAscending variables
- static wxCriticalSection gs_critsectStringSort;
+ static wxCriticalSection *gs_critsectStringSort = NULL;
// call this before the value of the global sort vars is changed/after
// you're finished with them
- #define START_SORT() gs_critsectStringSort.Enter()
- #define END_SORT() gs_critsectStringSort.Leave()
+ #define START_SORT() wxASSERT( !gs_critsectStringSort ); \
+ gs_critsectStringSort = new wxCriticalSection; \
+ gs_critsectStringSort->Enter()
+ #define END_SORT() gs_critsectStringSort->Leave(); \
+ delete gs_critsectStringSort; \
+ gs_critsectStringSort = NULL
#else // !threads
#define START_SORT()
#define END_SORT()
wxCriticalSection::wxCriticalSection()
{
- m_critsect = NULL;
+ m_critsect = new wxCriticalSectionInternal;
}
wxCriticalSection::~wxCriticalSection()
{
- wxASSERT_MSG( !m_critsect, "Forgot to Leave() critical section" );
+ delete m_critsect;
}
void wxCriticalSection::Enter()
{
- m_critsect = new wxCriticalSectionInternal;
-
::EnterCriticalSection(*m_critsect);
}
void wxCriticalSection::Leave()
{
- wxCHECK_RET( m_critsect, "Leave() without matching Enter()" );
-
::LeaveCriticalSection(*m_critsect);
-
- delete m_critsect;
- m_critsect = NULL;
}
// ----------------------------------------------------------------------------