Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retire atomicLoadAcquire() #4320

Merged
merged 1 commit into from
Sep 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/controllers/bulk/bulkcontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ void BulkReader::run() {
m_stop = 0;
unsigned char data[255];

while (atomicLoadAcquire(m_stop) == 0) {
while (m_stop.loadAcquire() == 0) {
// Blocked polling: The only problem with this is that we can't close
// the device until the block is released, which means the controller
// has to send more data
Expand Down
2 changes: 1 addition & 1 deletion src/engine/cachingreader/cachingreader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ void CachingReader::process() {
update.status == CHUNK_READ_EOF ||
update.status == CHUNK_READ_INVALID ||
update.status == CHUNK_READ_DISCARDED);
if (atomicLoadAcquire(m_state) == STATE_TRACK_LOADING) {
if (m_state.loadAcquire() == STATE_TRACK_LOADING) {
// Discard all results from pending read requests for the
// previous track before the next track has been loaded.
freeChunk(pChunk);
Expand Down
2 changes: 1 addition & 1 deletion src/engine/cachingreader/cachingreaderworker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ void CachingReaderWorker::run() {
QThread::currentThread()->setObjectName(QString("CachingReaderWorker %1").arg(++id));

Event::start(m_tag);
while (!atomicLoadAcquire(m_stop)) {
while (!m_stop.loadAcquire()) {
// Request is initialized by reading from FIFO
CachingReaderChunkReadRequest request;
if (m_newTrackAvailable) {
Expand Down
4 changes: 2 additions & 2 deletions src/library/export/trackexportworker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ void TrackExportWorker::run() {
// on the bar, which looks really nice.
emit progress(it->fileName(), i, copy_list.size());
copyFile((*it).asFileInfo(), it.key());
if (atomicLoadAcquire(m_bStop)) {
if (m_bStop.loadAcquire()) {
emit canceled();
return;
}
Expand Down Expand Up @@ -162,7 +162,7 @@ TrackExportWorker::OverwriteAnswer TrackExportWorker::makeOverwriteRequest(

// We can be either canceled from the other thread, or as a return value
// from this call. First check for a call from the other thread.
if (atomicLoadAcquire(m_bStop)) {
if (m_bStop.loadAcquire()) {
return OverwriteAnswer::CANCEL;
}

Expand Down
28 changes: 0 additions & 28 deletions src/util/compatibility.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,34 +128,6 @@ inline QScreen* getPrimaryScreen() {
return nullptr;
}

template <typename T>
inline T atomicLoadAcquire(const QAtomicInteger<T>& atomicInt) {
// TODO: QBasicAtomicInteger<T>::load() is deprecated and should be
// replaced with QBasicAtomicInteger<T>::loadRelaxed() However, the
// proposed alternative has just been introduced in Qt 5.14. Until the
// minimum required Qt version of Mixxx is increased, we need a version
// check here
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
return atomicInt.loadAcquire();
#else
return atomicInt.load();
#endif
}

template <typename T>
inline T* atomicLoadAcquire(const QAtomicPointer<T>& atomicPtr) {
// TODO: QBasicAtomicPointer<T>::load() is deprecated and should be
// replaced with QBasicAtomicPointer<T>::loadRelaxed() However, the
// proposed alternative has just been introduced in Qt 5.14. Until the
// minimum required Qt version of Mixxx is increased, we need a version
// check here
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
return atomicPtr.loadAcquire();
#else
return atomicPtr.load();
#endif
}

template <typename T>
inline T atomicLoadRelaxed(const QAtomicInteger<T>& atomicInt) {
// TODO: QBasicAtomicInteger<T>::load() is deprecated and should be
Expand Down
4 changes: 2 additions & 2 deletions src/util/statsmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,15 +248,15 @@ void StatsManager::run() {
processIncomingStatReports();
m_statsPipeLock.unlock();

if (atomicLoadAcquire(m_emitAllStats) == 1) {
if (m_emitAllStats.loadAcquire() == 1) {
for (auto it = m_stats.constBegin();
it != m_stats.constEnd(); ++it) {
emit statUpdated(it.value());
}
m_emitAllStats = 0;
}

if (atomicLoadAcquire(m_quit) == 1) {
if (m_quit.loadAcquire() == 1) {
qDebug() << "StatsManager thread shutting down.";
break;
}
Expand Down
2 changes: 1 addition & 1 deletion src/waveform/waveform.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class Waveform {
// Atomically lookup the completion of the waveform. Represents the number
// of data elements that have been processed out of dataSize.
int getCompletion() const {
return atomicLoadAcquire(m_completion);
return m_completion.loadAcquire();
}
void setCompletion(int completion) {
m_completion = completion;
Expand Down