From 66c8437952f970a1a896d67c0ba6838591cf03b6 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 1 Jun 2020 15:10:24 +0200 Subject: [PATCH] Add notes about standard threading classes to the documentation There is no reason to use wxMutex and wxCondition in C++11 programs as they have about the same API as the corresponding standard classes but are, well, non-standard. wxThread API is different from std::thread, so it's a less obvious replacement, but still at least mention the standard class in its documentation. --- interface/wx/thread.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/interface/wx/thread.h b/interface/wx/thread.h index 9eedf87a42..96ed7dcdd8 100644 --- a/interface/wx/thread.h +++ b/interface/wx/thread.h @@ -23,6 +23,8 @@ enum wxCondError They may be used in a multithreaded application to wait until the given condition becomes @true which happens when the condition becomes signaled. + @note In C++11 programs, prefer using @c std::condition to this class. + For example, if a worker thread is doing some long task and another thread has to wait until it is finished, the latter thread will wait on the condition object and the worker thread will signal it on exit (this example is not @@ -720,6 +722,8 @@ enum wxThreadError between threads and processes is that memory spaces of different processes are separated while all threads share the same address space. + @note In C++11 programs, consider using @c std::thread instead of this class. + While it makes it much easier to share common data between several threads, it also makes it much easier to shoot oneself in the foot, so careful use of synchronization objects such as mutexes (see wxMutex) or critical sections @@ -1569,6 +1573,8 @@ enum wxMutexError from its usefulness in coordinating mutually-exclusive access to a shared resource as only one thread at a time can own a mutex object. + @note In C++11 programs, prefer using @c std::mutex to this class. + Mutexes may be recursive in the sense that a thread can lock a mutex which it 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