#ifndef __THREADH__
#define __THREADH__
-#ifdef __GNUG__
- #pragma interface "thread.h"
-#endif
-
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#include "wx/setup.h"
#if wxUSE_THREADS
+/* otherwise we get undefined references for non-thread case (KB)*/
+#ifdef __GNUG__
+ #pragma interface "thread.h"
+#endif
// Windows headers define it
#ifdef Yield
{
public:
// lock the mutex in the ctor
- wxMutexLocker(wxMutex *mutex)
- { m_isOk = mutex && ((m_mutex = mutex)->Lock() == wxMUTEX_NO_ERROR); }
+ wxMutexLocker(wxMutex& mutex) : m_mutex(mutex)
+ { m_isOk = m_mutex.Lock() == wxMUTEX_NO_ERROR; }
// returns TRUE if mutex was successfully locked in ctor
- bool IsOk() const { return m_isOk; }
+ bool IsOk() const
+ { return m_isOk; }
// unlock the mutex in dtor
- ~wxMutexLocker() { if ( IsOk() ) m_mutex->Unlock(); }
+ ~wxMutexLocker()
+ { if ( IsOk() ) m_mutex.Unlock(); }
private:
// no assignment operator nor copy ctor
wxMutexLocker& operator=(const wxMutexLocker&);
bool m_isOk;
- wxMutex *m_mutex;
+ wxMutex& m_mutex;
};
// ----------------------------------------------------------------------------
// in order to avoid any overhead under !MSW make all wxCriticalSection class
// functions inline - but this can't be done under MSW
-#ifdef __WXMSW__
+#if defined(__WXMSW__) || defined(__WXPM__)
class WXDLLEXPORT wxCriticalSectionInternal;
#define WXCRITICAL_INLINE
#else // !MSW
WXCRITICAL_INLINE ~wxCriticalSection();
// enter the section (the same as locking a mutex)
- void WXCRITICAL_INLINE Enter();
+ WXCRITICAL_INLINE void Enter();
// leave the critical section (same as unlocking a mutex)
- void WXCRITICAL_INLINE Leave();
+ WXCRITICAL_INLINE void Leave();
private:
// no assignment operator nor copy ctor
wxCriticalSection(const wxCriticalSection&);
wxCriticalSection& operator=(const wxCriticalSection&);
-#ifdef __WXMSW__
+#if defined(__WXMSW__) || defined(__WXPM__)
wxCriticalSectionInternal *m_critsect;
#else // !MSW
wxMutex m_mutex;
// Returns true if the thread is running (not paused, not killed).
bool IsRunning() const;
// Returns true if the thread is suspended
- bool IsPaused() const { return IsAlive() && !IsRunning(); }
+ bool IsPaused() const;
// called when the thread exits - in the context of this thread
//
// Returns TRUE if the thread was asked to terminate: this function should
// be called by the thread from time to time, otherwise the main thread
// will be left forever in Delete()!
- bool TestDestroy() const;
+ bool TestDestroy();
// exits from the current thread - can be called only from this thread
void Exit(void *exitcode = 0);
#else // !wxUSE_THREADS
+#include <wx/defs.h> // for WXDLLEXPORT
+
// no thread support
inline void WXDLLEXPORT wxMutexGuiEnter() { }
inline void WXDLLEXPORT wxMutexGuiLeave() { }
// -----------------------------------------------------------------------------
// implementation only until the end of file
// -----------------------------------------------------------------------------
-#ifdef wxUSE_THREADS
-#ifdef __WXMSW__
+#if wxUSE_THREADS
+#if defined(__WXMSW__) || defined(__WXPM__)
// unlock GUI if there are threads waiting for and lock it back when
// there are no more of them - should be called periodically by the main
// thread