diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2023-05-01 16:05:21 -0700 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2023-05-31 14:54:57 -0700 |
commit | 2e1318f691547e159b28fb738858738e621464e4 (patch) | |
tree | dd99877f6c83baebb134225c79611acf879bc16a /src/corelib/thread/qsemaphore.cpp | |
parent | 52fa66d0877e911400017789461ec36df619797b (diff) |
QSemaphore: add a note to update to noexcept in Qt 7
The QSemaphore acquire & release functions, plus the constructor and
destructor, can be made noexcept on platforms that use futexes
(currently, Linux and Windows; likely macOS by the time we make 7.0). I
didn't make the change right now because the acquire and release
functions have narrow contracts on the int n values. I didn't make that
change now because it make a mess of the code, for little gain as this
class isn't used that often.
Plus, we may want to investigate whether we want to keep the multi-token
semaphore functionality around (something neither POSIX sem_t nor
std::counting_semaphore have), or split that off into a separate class
like QBasicMutex / QMutex / QRecursiveMutex was done.
Change-Id: Ieab617d69f3b4b54ab30fffd175b27813728f2ce
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Diffstat (limited to 'src/corelib/thread/qsemaphore.cpp')
-rw-r--r-- | src/corelib/thread/qsemaphore.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/corelib/thread/qsemaphore.cpp b/src/corelib/thread/qsemaphore.cpp index af34a7bb39..a7b423e4e7 100644 --- a/src/corelib/thread/qsemaphore.cpp +++ b/src/corelib/thread/qsemaphore.cpp @@ -300,7 +300,12 @@ QSemaphore::~QSemaphore() */ void QSemaphore::acquire(int n) { +#if QT_VERSION >= QT_VERSION_CHECK(7, 0, 0) +# warning "Move the Q_ASSERT to inline code, make QSemaphore have wide contract, " \ + "and mark noexcept where futexes are in use." +#else Q_ASSERT_X(n >= 0, "QSemaphore::acquire", "parameter 'n' must be non-negative"); +#endif if (futexAvailable()) { futexSemaphoreTryAcquire(u, n, QDeadlineTimer::Forever); |