ThreadWeaver

lambda.h
1 /* -*- C++ -*-
2  Wrap functors in jobs in ThreadWeaver.
3 
4  SPDX-FileCopyrightText: 2005-2013 Mirko Boehm <[email protected]>
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 
15 namespace ThreadWeaver
16 {
17 /** @brief Lambda is a template that takes any type on which operator() is available, and executes it in run(). */
18 template<typename T>
19 class Lambda : public Job
20 {
21 public:
22  explicit Lambda(T t_)
23  : t(t_)
24  {
25  }
26 
27 protected:
28  void run(JobPointer, Thread *) override
29  {
30  t();
31  }
32 
33 private:
34  T t;
35 };
36 
37 }
38 
39 #endif // LAMBDA_H
Lambda is a template that takes any type on which operator() is available, and executes it in run().
Definition: lambda.h:19
A Job is a simple abstraction of an action that is to be executed in a thread context.
Definition: job.h:46
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:27
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Fri Sep 22 2023 04:03:25 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.