QSemaphoreReleaser: two minor code improvements
- use qExchange() in cancel() - use cancel() instead of manual pointer manipulations in the move ctor Change-Id: Ica3a3a1e339500c5e5a0c0646e7a95c7c5d435db Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This commit is contained in:
parent
72106832e4
commit
2c0ad8dd3a
@ -80,8 +80,7 @@ public:
|
||||
explicit QSemaphoreReleaser(QSemaphore *sem, int n = 1) noexcept
|
||||
: m_sem(sem), m_n(n) {}
|
||||
QSemaphoreReleaser(QSemaphoreReleaser &&other) noexcept
|
||||
: m_sem(other.m_sem), m_n(other.m_n)
|
||||
{ other.m_sem = nullptr; }
|
||||
: m_sem(other.cancel()), m_n(other.m_n) {}
|
||||
QSemaphoreReleaser &operator=(QSemaphoreReleaser &&other) noexcept
|
||||
{ QSemaphoreReleaser moved(std::move(other)); swap(moved); return *this; }
|
||||
|
||||
@ -102,9 +101,7 @@ public:
|
||||
|
||||
QSemaphore *cancel() noexcept
|
||||
{
|
||||
QSemaphore *old = m_sem;
|
||||
m_sem = nullptr;
|
||||
return old;
|
||||
return qExchange(m_sem, nullptr);
|
||||
}
|
||||
|
||||
private:
|
||||
|
Loading…
Reference in New Issue
Block a user