Classes | |
class | wxCondition |
wxCondition variables correspond to pthread conditions or to Win32 event objects. More... | |
class | wxCriticalSectionLocker |
This is a small helper class to be used with wxCriticalSection objects. More... | |
class | wxThreadHelper |
The wxThreadHelper class is a mix-in class that manages a single background thread, either detached or joinable (see wxThread for the differences). More... | |
class | wxCriticalSection |
A critical section object is used for exactly the same purpose as a wxMutex. More... | |
class | wxThread |
A thread is basically a path of execution through a program. More... | |
class | wxSemaphore |
wxSemaphore is a counter limiting the number of threads concurrently accessing a shared resource. More... | |
class | wxMutexLocker |
This is a small helper class to be used with wxMutex objects. More... | |
class | wxMutex |
A mutex object is a synchronization object whose state is set to signaled when it is not owned by any thread, and nonsignaled when it is owned. More... | |
Macros | |
#define | wxCRIT_SECT_DECLARE(cs) |
This macro declares a (static) critical section object named cs if wxUSE_THREADS is 1 and does nothing if it is 0. | |
#define | wxCRIT_SECT_DECLARE_MEMBER(cs) |
This macro declares a critical section object named cs if wxUSE_THREADS is 1 and does nothing if it is 0. | |
#define | wxCRIT_SECT_LOCKER(name, cs) |
This macro creates a wxCriticalSectionLocker named name and associated with the critical section cs if wxUSE_THREADS is 1 and does nothing if it is 0. | |
#define | wxCRITICAL_SECTION(name) |
This macro combines wxCRIT_SECT_DECLARE() and wxCRIT_SECT_LOCKER(): it creates a static critical section object and also the lock object associated with it. | |
#define | wxLEAVE_CRIT_SECT(critical_section) |
This macro is equivalent to critical_section.Leave() if wxUSE_THREADS is 1 and does nothing if it is 0. | |
#define | wxENTER_CRIT_SECT(critical_section) |
This macro is equivalent to critical_section.Enter() if wxUSE_THREADS is 1 and does nothing if it is 0. | |
Functions | |
bool | wxIsMainThread () |
Returns true if this thread is the main one. | |
void | wxMutexGuiEnter () |
This function must be called when any thread other than the main GUI thread wants to get access to the GUI library. | |
void | wxMutexGuiLeave () |
This function is only defined on platforms which support preemptive threads. | |
#define wxCRIT_SECT_DECLARE | ( | cs | ) |
This macro declares a (static) critical section object named cs if wxUSE_THREADS
is 1 and does nothing if it is 0.
Include file:
#include <wx/thread.h>
#define wxCRIT_SECT_DECLARE_MEMBER | ( | cs | ) |
This macro declares a critical section object named cs if wxUSE_THREADS
is 1 and does nothing if it is 0.
As it doesn't include the static
keyword (unlike wxCRIT_SECT_DECLARE()), it can be used to declare a class or struct member which explains its name.
Include file:
#include <wx/thread.h>
#define wxCRIT_SECT_LOCKER | ( | name, | |
cs | |||
) |
This macro creates a wxCriticalSectionLocker named name and associated with the critical section cs if wxUSE_THREADS
is 1 and does nothing if it is 0.
Include file:
#include <wx/thread.h>
#define wxCRITICAL_SECTION | ( | name | ) |
This macro combines wxCRIT_SECT_DECLARE() and wxCRIT_SECT_LOCKER(): it creates a static critical section object and also the lock object associated with it.
Because of this, it can be only used inside a function, not at global scope. For example:
Note that this example assumes that the function is called the first time from the main thread so that the critical section object is initialized correctly by the time other threads start calling it, if this is not the case this approach can not be used and the critical section must be made a global instead.
Include file:
#include <wx/thread.h>
#define wxENTER_CRIT_SECT | ( | critical_section | ) |
This macro is equivalent to critical_section.Enter() if wxUSE_THREADS
is 1 and does nothing if it is 0.
Include file:
#include <wx/thread.h>
#define wxLEAVE_CRIT_SECT | ( | critical_section | ) |
This macro is equivalent to critical_section.Leave() if wxUSE_THREADS
is 1 and does nothing if it is 0.
Include file:
#include <wx/thread.h>
enum wxCondError |
See wxCondition.
Enumerator | |
---|---|
wxCOND_NO_ERROR | |
wxCOND_INVALID | |
wxCOND_TIMEOUT | WaitTimeout() has timed out. |
wxCOND_MISC_ERROR |
enum wxMutexError |
The possible wxMutex errors.
Enumerator | |
---|---|
wxMUTEX_NO_ERROR | The operation completed successfully. |
wxMUTEX_INVALID | The mutex hasn't been initialized. |
wxMUTEX_DEAD_LOCK | The mutex is already locked by the calling thread. |
wxMUTEX_BUSY | The mutex is already locked by another thread. |
wxMUTEX_UNLOCKED | An attempt to unlock a mutex which is not locked. |
wxMUTEX_TIMEOUT | wxMutex::LockTimeout() has timed out. |
wxMUTEX_MISC_ERROR | Any other error. |
enum wxMutexType |
The possible wxMutex kinds.
Enumerator | |
---|---|
wxMUTEX_DEFAULT | Normal non-recursive mutex: try to always use this one. |
wxMUTEX_RECURSIVE | Recursive mutex: don't use these ones with wxCondition. |
enum wxSemaError |
See wxSemaphore.
enum wxThreadError |
The possible thread errors.
enum wxThreadKind |
enum wxThreadWait |
The possible thread wait types.
Enumerator | |
---|---|
wxTHREAD_WAIT_BLOCK | No events are processed while waiting. This is the default under all platforms except for wxMSW. |
wxTHREAD_WAIT_YIELD | Yield for event dispatching while waiting. This flag is dangerous as it exposes the program using it to unexpected reentrancies in the same way as calling wxYield() function does so you are strongly advised to avoid its use and not wait for the thread termination from the main (GUI) thread at all to avoid making your application unresponsive. Also notice that this flag is not portable as it is only implemented in wxMSW and simply ignored under the other platforms. |
wxTHREAD_WAIT_DEFAULT | Default wait mode for wxThread::Wait() and wxThread::Delete(). For compatibility reasons, the default wait mode is currently wxTHREAD_WAIT_YIELD if WXWIN_COMPATIBILITY_2_8 is defined (and it is by default). However, as mentioned above, you're strongly encouraged to not use wxTHREAD_WAIT_YIELD and pass wxTHREAD_WAIT_BLOCK to wxThread method explicitly. |
bool wxIsMainThread | ( | ) |
Returns true if this thread is the main one.
Always returns true if wxUSE_THREADS
is 0.
Include file:
#include <wx/thread.h>
void wxMutexGuiEnter | ( | ) |
This function must be called when any thread other than the main GUI thread wants to get access to the GUI library.
This function will block the execution of the calling thread until the main thread (or any other thread holding the main GUI lock) leaves the GUI library and no other thread will enter the GUI library until the calling thread calls wxMutexGuiLeave().
Typically, these functions are used like this:
This function is only defined on platforms which support preemptive threads and only works under some ports (wxMSW currently).
Include file:
#include <wx/thread.h>
void wxMutexGuiLeave | ( | ) |
This function is only defined on platforms which support preemptive threads.
Include file:
#include <wx/thread.h>