Eigen  3.4.90 (git rev 5a9f66fb35d03a4da9ef8976e67a61b30aa16dcf)
 
Loading...
Searching...
No Matches
ThreadPoolInterface.h
1// This file is part of Eigen, a lightweight C++ template library
2// for linear algebra.
3//
4// Copyright (C) 2014 Benoit Steiner <[email protected]>
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_POOL_INTERFACE_H
11#define EIGEN_CXX11_THREADPOOL_THREAD_POOL_INTERFACE_H
12
13// IWYU pragma: private
14#include "./InternalHeaderCheck.h"
15
16namespace Eigen {
17
18// This defines an interface that ThreadPoolDevice can take to use
19// custom thread pools underneath.
20class ThreadPoolInterface {
21 public:
22 // Submits a closure to be run by a thread in the pool.
23 virtual void Schedule(std::function<void()> fn) = 0;
24
25 // Submits a closure to be run by threads in the range [start, end) in the
26 // pool.
27 virtual void ScheduleWithHint(std::function<void()> fn, int /*start*/, int /*end*/) {
28 // Just defer to Schedule in case sub-classes aren't interested in
29 // overriding this functionality.
30 Schedule(fn);
31 }
32
33 // If implemented, stop processing the closures that have been enqueued.
34 // Currently running closures may still be processed.
35 // If not implemented, does nothing.
36 virtual void Cancel() {}
37
38 // Returns the number of threads in the pool.
39 virtual int NumThreads() const = 0;
40
41 // Returns a logical thread index between 0 and NumThreads() - 1 if called
42 // from one of the threads in the pool. Returns -1 otherwise.
43 virtual int CurrentThreadId() const = 0;
44
45 virtual ~ThreadPoolInterface() {}
46};
47
48} // namespace Eigen
49
50#endif // EIGEN_CXX11_THREADPOOL_THREAD_POOL_INTERFACE_H
Namespace containing all symbols from the Eigen library.
Definition Core:137