ThreadEnvironment.h
Go to the documentation of this file.
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2014 Benoit Steiner <benoit.steiner.goog@gmail.com>
5 //
6 // This Source Code Form is subject to the terms of the Mozilla
7 // Public License v. 2.0. If a copy of the MPL was not distributed
8 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 
10 #ifndef EIGEN_CXX11_THREADPOOL_THREAD_ENVIRONMENT_H
11 #define EIGEN_CXX11_THREADPOOL_THREAD_ENVIRONMENT_H
12 
13 namespace Eigen {
14 
16  struct Task {
17  std::function<void()> f;
18  };
19 
20  // EnvThread constructor must start the thread,
21  // destructor must join the thread.
22  class EnvThread {
23  public:
24  EnvThread(std::function<void()> f) : thr_(std::move(f)) {}
25  ~EnvThread() { thr_.join(); }
26 
27  private:
28  std::thread thr_;
29  };
30 
31  EnvThread* CreateThread(std::function<void()> f) { return new EnvThread(std::move(f)); }
32  Task CreateTask(std::function<void()> f) { return Task{std::move(f)}; }
33  void ExecuteTask(const Task& t) { t.f(); }
34 };
35 
36 } // namespace Eigen
37 
38 #endif // EIGEN_CXX11_THREADPOOL_THREAD_ENVIRONMENT_H
EnvThread * CreateThread(std::function< void()> f)
Namespace containing all symbols from the Eigen library.
Definition: jet.h:637
Definition: Half.h:150
Task CreateTask(std::function< void()> f)
detail::enable_if_t<!detail::move_never< T >::value, T > move(object &&obj)
Definition: cast.h:1756
void ExecuteTask(const Task &t)
Point2 t(10, 10)


gtsam
Author(s):
autogenerated on Sat May 8 2021 02:50:25