diff --git a/src/concurrent/qtconcurrentrun.h b/src/concurrent/qtconcurrentrun.h index cf153ab34e6..cbc750de84f 100644 --- a/src/concurrent/qtconcurrentrun.h +++ b/src/concurrent/qtconcurrentrun.h @@ -35,8 +35,11 @@ namespace QtConcurrent { namespace QtConcurrent { +#define QTCONCURRENT_RUN_NODISCARD \ + Q_NODISCARD_X("Use QThreadPool::start(Callable&&) if you don't need the returned QFuture") + template -[[nodiscard]] +QTCONCURRENT_RUN_NODISCARD auto run(QThreadPool *pool, Function &&f, Args &&...args) { DecayedTuple tuple { std::forward(f), @@ -46,7 +49,7 @@ auto run(QThreadPool *pool, Function &&f, Args &&...args) } template -[[nodiscard]] +QTCONCURRENT_RUN_NODISCARD auto run(QThreadPool *pool, std::reference_wrapper &&functionWrapper, Args &&...args) { @@ -55,7 +58,7 @@ auto run(QThreadPool *pool, std::reference_wrapper &&functionWra } template -[[nodiscard]] +QTCONCURRENT_RUN_NODISCARD auto run(Function &&f, Args &&...args) { return run(QThreadPool::globalInstance(), std::forward(f), @@ -64,7 +67,7 @@ auto run(Function &&f, Args &&...args) // overload with a Promise Type hint, takes thread pool template -[[nodiscard]] +QTCONCURRENT_RUN_NODISCARD auto run(QThreadPool *pool, Function &&f, Args &&...args) { return (new StoredFunctionCallWithPromise( @@ -73,13 +76,15 @@ auto run(QThreadPool *pool, Function &&f, Args &&...args) // overload with a Promise Type hint, uses global thread pool template -[[nodiscard]] +QTCONCURRENT_RUN_NODISCARD auto run(Function &&f, Args &&...args) { return run(QThreadPool::globalInstance(), std::forward(f), std::forward(args)...); } +#undef QTCONCURRENT_RUN_NODISCARD + } //namespace QtConcurrent #endif // Q_QDOC