diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-02-25 16:16:42 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-02-26 06:25:20 +0100 |
commit | 23c5fc1d2fa9d9ff51129280288d13c935105b10 (patch) | |
tree | 176188935ec3473af15b0a38883cd475a01b9de4 /src/corelib/thread/qthreadpool.cpp | |
parent | 165d2f09cd9a7f8a17da430846cbeb9dc51f55be (diff) |
Improve argument name for std::function argument
Less \a fun though.
Note using references in this API would just duplicate the API, but
still end up with a copy when creating the QRunnable. By having the
copy apparent directly in the API, we not only save the duplication,
we also hint to the caller to use move if they want to avoid a copy.
Change-Id: If11476d4b38853839c1e87e0339807a1798fc875
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/thread/qthreadpool.cpp')
-rw-r--r-- | src/corelib/thread/qthreadpool.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/corelib/thread/qthreadpool.cpp b/src/corelib/thread/qthreadpool.cpp index d1875a69a9..a9352c3894 100644 --- a/src/corelib/thread/qthreadpool.cpp +++ b/src/corelib/thread/qthreadpool.cpp @@ -515,16 +515,16 @@ void QThreadPool::start(QRunnable *runnable, int priority) \overload \since 5.15 - Reserves a thread and uses it to run \a fun, unless this thread will + Reserves a thread and uses it to run \a functionToRun, unless this thread will make the current thread count exceed maxThreadCount(). In that case, - \a fun is added to a run queue instead. The \a priority argument can + \a functionToRun is added to a run queue instead. The \a priority argument can be used to control the run queue's order of execution. */ -void QThreadPool::start(std::function<void()> fun, int priority) +void QThreadPool::start(std::function<void()> functionToRun, int priority) { - if (!fun) + if (!functionToRun) return; - start(QRunnable::create(std::move(fun)), priority); + start(QRunnable::create(std::move(functionToRun)), priority); } /*! @@ -561,17 +561,17 @@ bool QThreadPool::tryStart(QRunnable *runnable) /*! \overload \since 5.15 - Attempts to reserve a thread to run \a fun. + Attempts to reserve a thread to run \a functionToRun. If no threads are available at the time of calling, then this function - does nothing and returns \c false. Otherwise, \a fun is run immediately + does nothing and returns \c false. Otherwise, \a functionToRun is run immediately using one available thread and this function returns \c true. */ -bool QThreadPool::tryStart(std::function<void()> fun) +bool QThreadPool::tryStart(std::function<void()> functionToRun) { - if (!fun) + if (!functionToRun) return false; - return tryStart(QRunnable::create(std::move(fun))); + return tryStart(QRunnable::create(std::move(functionToRun))); } /*! \property QThreadPool::expiryTimeout |