ThreadWeaver

lambda.h
1/* -*- C++ -*-
2 Wrap functors in jobs in ThreadWeaver.
3
4 SPDX-FileCopyrightText: 2005-2013 Mirko Boehm <mirko@kde.org>
5
6 SPDX-License-Identifier: LGPL-2.0-or-later
7*/
8
9#ifndef LAMBDA_H
10#define LAMBDA_H
11
12#include "job.h"
13#include "threadweaver_export.h"
14
15namespace ThreadWeaver
16{
17/** @brief Lambda is a template that takes any type on which operator() is available, and executes it in run(). */
18template<typename T>
19class Lambda : public Job
20{
21public:
22 explicit Lambda(T t_)
23 : t(t_)
24 {
25 }
26
27protected:
28 void run(JobPointer, Thread *) override
29 {
30 t();
31 }
32
33private:
34 T t;
35};
36
37}
38
39#endif // LAMBDA_H
A Job is a simple abstraction of an action that is to be executed in a thread context.
Definition job.h:47
Lambda is a template that takes any type on which operator() is available, and executes it in run().
Definition lambda.h:20
void run(JobPointer, Thread *) override
The method that actually performs the job.
Definition lambda.h:28
Thread represents a worker thread in a Queue's inventory.
Definition thread.h:28
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jul 19 2024 11:53:19 by doxygen 1.11.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.