improved Lambda support

This commit is contained in:
Günter Obiltschnig
2020-01-26 08:41:22 +01:00
parent 14e58b7fea
commit 958387b6ba
6 changed files with 122 additions and 43 deletions

View File

@@ -154,12 +154,19 @@ public:
/// Starts the thread with the given target and parameter.
template <class Functor>
void startFunc(Functor fn)
void startFunc(const Functor& fn)
/// Starts the thread with the given functor object or lambda.
{
startImpl(new FunctorRunnable<Functor>(fn));
}
template <class Functor>
void startFunc(Functor&& fn)
/// Starts the thread with the given functor object or lambda.
{
startImpl(new FunctorRunnable<Functor>(std::move(fn)));
}
void join();
/// Waits until the thread completes execution.
/// If multiple threads try to join the same
@@ -242,6 +249,11 @@ protected:
{
}
FunctorRunnable(Functor&& functor):
_functor(std::move(functor))
{
}
~FunctorRunnable()
{
}