Eigen
5.0.1
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 <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
// SPDX-License-Identifier: MPL-2.0
10
11
#ifndef EIGEN_THREADPOOL_THREAD_POOL_INTERFACE_H
12
#define EIGEN_THREADPOOL_THREAD_POOL_INTERFACE_H
13
14
// IWYU pragma: private
15
#include "./InternalHeaderCheck.h"
16
17
namespace
Eigen {
18
19
// This defines an interface that ThreadPoolDevice can take to use
20
// custom thread pools underneath.
21
class
ThreadPoolInterface {
22
public
:
23
// Submits a closure to be run by a thread in the pool.
24
virtual
void
Schedule(std::function<
void
()> fn) = 0;
25
26
// Submits a closure to be run by threads in the range [start, end) in the
27
// pool.
28
virtual
void
ScheduleWithHint(std::function<
void
()> fn,
int
/*start*/
,
int
/*end*/
) {
29
// Just defer to Schedule in case sub-classes aren't interested in
30
// overriding this functionality.
31
Schedule(fn);
32
}
33
34
// If implemented, stop processing the closures that have been enqueued.
35
// Currently running closures may still be processed.
36
// If not implemented, does nothing.
37
virtual
void
Cancel() {}
38
39
// Returns the number of threads in the pool.
40
virtual
int
NumThreads()
const
= 0;
41
42
// Returns a logical thread index between 0 and NumThreads() - 1 if called
43
// from one of the threads in the pool. Returns -1 otherwise.
44
virtual
int
CurrentThreadId()
const
= 0;
45
46
virtual
~ThreadPoolInterface() =
default
;
47
};
48
49
}
// namespace Eigen
50
51
#endif
// EIGEN_THREADPOOL_THREAD_POOL_INTERFACE_H
Eigen
src
ThreadPool
ThreadPoolInterface.h
Generated by
1.13.2