diff options
author | Uwe Klotz <uklotz@mixxx.org> | 2020-12-31 10:08:46 +0100 |
---|---|---|
committer | Uwe Klotz <uklotz@mixxx.org> | 2020-12-31 10:09:45 +0100 |
commit | 08adfd7a8ebd5ec4fc5330ed4f4fab6777aafbd3 (patch) | |
tree | 7009c00d06c6bcdfcee267345ac1aa6ead94af6b /src/network | |
parent | d1def9b46012c0c2f60306648237ca9b3e8a82b0 (diff) |
WebTask: Document and verify thread affininty
Diffstat (limited to 'src/network')
-rw-r--r-- | src/network/webtask.cpp | 1 | ||||
-rw-r--r-- | src/network/webtask.h | 16 |
2 files changed, 14 insertions, 3 deletions
diff --git a/src/network/webtask.cpp b/src/network/webtask.cpp index 229d81aa54..9c60162086 100644 --- a/src/network/webtask.cpp +++ b/src/network/webtask.cpp @@ -173,6 +173,7 @@ void WebTask::slotStart(int timeoutMillis) { QByteArray()); return; } + DEBUG_ASSERT_QOBJECT_THREAD_AFFINITY(pNetworkAccessManager); kLogger.debug() << this diff --git a/src/network/webtask.h b/src/network/webtask.h index 550295f362..a268318136 100644 --- a/src/network/webtask.h +++ b/src/network/webtask.h @@ -104,16 +104,20 @@ class WebTask : public QObject { QObject* parent = nullptr); ~WebTask() override; + /// Start a new task by sending a network request. + /// /// timeoutMillis <= 0: No timeout (unlimited) /// timeoutMillis > 0: Implicitly aborted after timeout expired + /// + /// This function is thread-safe and could be invoked from any thread. void invokeStart( int timeoutMillis = 0); - /// Cancel a pending request. + /// Cancel the task by aborting the pending network request. + /// + /// This function is thread-safe and could be invoked from any thread. void invokeAbort(); - /// Cancel a pending request from the event loop thread. - void abort(); public slots: void slotStart( int timeoutMillis); @@ -137,6 +141,12 @@ class WebTask : public QObject { const QByteArray& errorContent); protected: + /// Cancel the task by aborting the pending network request. + /// + /// This function is NOT thread-safe and must only be called from + /// the event loop thread. + void abort(); + template<typename S> bool isSignalFuncConnected( S signalFunc) { |