summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2020-02-25 16:16:42 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2020-02-26 06:25:20 +0100
commit23c5fc1d2fa9d9ff51129280288d13c935105b10 (patch)
tree176188935ec3473af15b0a38883cd475a01b9de4 /src
parent165d2f09cd9a7f8a17da430846cbeb9dc51f55be (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')
-rw-r--r--src/corelib/thread/qrunnable.cpp12
-rw-r--r--src/corelib/thread/qrunnable.h2
-rw-r--r--src/corelib/thread/qthreadpool.cpp20
-rw-r--r--src/corelib/thread/qthreadpool.h4
4 files changed, 19 insertions, 19 deletions
diff --git a/src/corelib/thread/qrunnable.cpp b/src/corelib/thread/qrunnable.cpp
index 58a764d407..c911cd0745 100644
--- a/src/corelib/thread/qrunnable.cpp
+++ b/src/corelib/thread/qrunnable.cpp
@@ -116,29 +116,29 @@ QRunnable::~QRunnable()
class FunctionRunnable : public QRunnable
{
- std::function<void()> m_functor;
+ std::function<void()> m_functionToRun;
public:
- FunctionRunnable(std::function<void()> functor) : m_functor(std::move(functor))
+ FunctionRunnable(std::function<void()> functionToRun) : m_functionToRun(std::move(functionToRun))
{
}
void run() override
{
- m_functor();
+ m_functionToRun();
}
};
/*!
\since 5.15
- Creates a QRunnable that calls \a fun in run().
+ Creates a QRunnable that calls \a functionToRun in run().
Auto-deletion is enabled by default.
\sa run(), autoDelete()
*/
-QRunnable *QRunnable::create(std::function<void()> fun)
+QRunnable *QRunnable::create(std::function<void()> functionToRun)
{
- return new FunctionRunnable(std::move(fun));
+ return new FunctionRunnable(std::move(functionToRun));
}
QT_END_NAMESPACE
diff --git a/src/corelib/thread/qrunnable.h b/src/corelib/thread/qrunnable.h
index c13aa3fa8c..26b6b991ac 100644
--- a/src/corelib/thread/qrunnable.h
+++ b/src/corelib/thread/qrunnable.h
@@ -60,7 +60,7 @@ public:
QRunnable() : ref(0) { }
virtual ~QRunnable();
- static QRunnable *create(std::function<void()> fun);
+ static QRunnable *create(std::function<void()> functionToRun);
bool autoDelete() const { return ref != -1; }
void setAutoDelete(bool _autoDelete) { ref = _autoDelete ? 0 : -1; }
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
diff --git a/src/corelib/thread/qthreadpool.h b/src/corelib/thread/qthreadpool.h
index 2eede44eca..e3691ab010 100644
--- a/src/corelib/thread/qthreadpool.h
+++ b/src/corelib/thread/qthreadpool.h
@@ -72,8 +72,8 @@ public:
void start(QRunnable *runnable, int priority = 0);
bool tryStart(QRunnable *runnable);
- void start(std::function<void()> fun, int priority = 0);
- bool tryStart(std::function<void()> fun);
+ void start(std::function<void()> functionToRun, int priority = 0);
+ bool tryStart(std::function<void()> functionToRun);
int expiryTimeout() const;
void setExpiryTimeout(int expiryTimeout);