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>
This commit is contained in:
parent
52fa66d087
commit
2e1318f691
@ -300,7 +300,12 @@ QSemaphore::~QSemaphore()
|
|||||||
*/
|
*/
|
||||||
void QSemaphore::acquire(int n)
|
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");
|
Q_ASSERT_X(n >= 0, "QSemaphore::acquire", "parameter 'n' must be non-negative");
|
||||||
|
#endif
|
||||||
|
|
||||||
if (futexAvailable()) {
|
if (futexAvailable()) {
|
||||||
futexSemaphoreTryAcquire(u, n, QDeadlineTimer::Forever);
|
futexSemaphoreTryAcquire(u, n, QDeadlineTimer::Forever);
|
||||||
|
Loading…
Reference in New Issue
Block a user