/**
The destructor frees the resources associated with the thread.
*/
- ~wxThreadHelper();
+ virtual ~wxThreadHelper();
/**
Creates a new thread. The thread object is created in the suspended state, and
This is a public function that returns the wxThread object
associated with the thread.
*/
- wxThread* GetThread();
+ wxThread* GetThread() const;
/**
wxThread * m_thread
*/
enum wxThreadKind
{
- wxTHREAD_DETACHED, /** Detached thread */
- wxTHREAD_JOINABLE /** Joinable thread */
+ /** Detached thread */
+ wxTHREAD_DETACHED,
+
+ /** Joinable thread */
+ wxTHREAD_JOINABLE
};
/**
*/
enum wxThreadError
{
- wxTHREAD_NO_ERROR = 0, /** No error */
- wxTHREAD_NO_RESOURCE, /** No resource left to create a new thread */
- wxTHREAD_RUNNING, /** The thread is already running */
- wxTHREAD_NOT_RUNNING, /** The thread isn't running */
- wxTHREAD_KILLED, /** Thread we waited for had to be killed */
- wxTHREAD_MISC_ERROR /** Some other error */
+ /** No error */
+ wxTHREAD_NO_ERROR = 0,
+
+ /** No resource left to create a new thread. */
+ wxTHREAD_NO_RESOURCE,
+
+ /** The thread is already running. */
+ wxTHREAD_RUNNING,
+
+ /** The thread isn't running. */
+ wxTHREAD_NOT_RUNNING,
+
+ /** Thread we waited for had to be killed. */
+ wxTHREAD_KILLED,
+
+ /** Some other error */
+ wxTHREAD_MISC_ERROR
};
/**
will not delete the C++ thread object. It is also safe to allocate them on
stack.
*/
- ~wxThread();
+ virtual ~wxThread();
/**
Creates a new thread. The thread object is created in the suspended state,
@ref Kill() killed.
This function should never be called directly.
*/
- void OnExit();
+ virtual void OnExit();
/**
Suspends the thread. Under some implementations (Win32), the thread is
information.
See also Sleep().
*/
- void Yield();
+ static void Yield();
};
/**
public:
/**
Constructs a wxMutexLocker object associated with mutex and locks it.
- Call @ref IsOk() IsLocked to check if the mutex was
- successfully locked.
+ Call IsOk() to check if the mutex was successfully locked.
*/
wxMutexLocker(wxMutex& mutex);
*/
enum wxMutexType
{
- wxMUTEX_DEFAULT, /** Normal mutex: try to always use this one. Recursive under Windows. */
+ /** Normal non-recursive mutex: try to always use this one. */
+ wxMUTEX_DEFAULT,
- wxMUTEX_RECURSIVE /** Recursive mutex: don't use these ones with wxCondition. */
+ /** Recursive mutex: don't use these ones with wxCondition. */
+ wxMUTEX_RECURSIVE
};
*/
enum wxMutexError
{
- wxMUTEX_NO_ERROR = 0, /** operation completed successfully */
- wxMUTEX_INVALID, /** mutex hasn't been initialized */
- wxMUTEX_DEAD_LOCK, /** mutex is already locked by the calling thread */
- wxMUTEX_BUSY, /** mutex is already locked by another thread */
- wxMUTEX_UNLOCKED, /** attempt to unlock a mutex which is not locked */
- wxMUTEX_TIMEOUT, /** LockTimeout() has timed out */
- wxMUTEX_MISC_ERROR /** any other error */
+ /** The operation completed successfully. */
+ wxMUTEX_NO_ERROR = 0,
+
+ /** The mutex hasn't been initialized. */
+ wxMUTEX_INVALID,
+
+ /** The mutex is already locked by the calling thread. */
+ wxMUTEX_DEAD_LOCK,
+
+ /** The mutex is already locked by another thread. */
+ wxMUTEX_BUSY,
+
+ /** An attempt to unlock a mutex which is not locked. */
+ wxMUTEX_UNLOCKED,
+
+ /** wxMutex::LockTimeout() has timed out. */
+ wxMUTEX_TIMEOUT,
+
+ /** Any other error */
+ wxMUTEX_MISC_ERROR
};
had already locked before (instead of dead locking the entire process in this
situation by starting to wait on a mutex which will never be released while the
thread is waiting) but using them is not recommended under Unix and they are
- @b not recursive there by default. The reason for this is that recursive
+ @b not recursive by default. The reason for this is that recursive
mutexes are not supported by all Unix flavours and, worse, they cannot be used
- with wxCondition. On the other hand, Win32 mutexes are always recursive.
+ with wxCondition.
For example, when several threads use the data stored in the linked list,
modifications to the list should only be allowed to one thread at a time
Locks the mutex object. This is equivalent to
LockTimeout() with infinite timeout.
- @return One of:
+ @return One of: @c wxMUTEX_NO_ERROR, @c wxMUTEX_DEAD_LOCK.
*/
wxMutexError Lock();
/**
Try to lock the mutex object during the specified time interval.
- @return One of:
+ @return One of: @c wxMUTEX_NO_ERROR, @c wxMUTEX_DEAD_LOCK, @c wxMUTEX_TIMEOUT.
*/
wxMutexError LockTimeout(unsigned long msec);
/**
Tries to lock the mutex object. If it can't, returns immediately with an error.
- @return One of:
+ @return One of: @c wxMUTEX_NO_ERROR, @c wxMUTEX_BUSY.
*/
wxMutexError TryLock();
/**
Unlocks the mutex object.
- @return One of:
+ @return One of: @c wxMUTEX_NO_ERROR, @c wxMUTEX_UNLOCKED.
*/
wxMutexError Unlock();
};