Home | History | Annotate | Download | only in ThreadPool
      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 (at) 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_POOL_INTERFACE_H
     11 #define EIGEN_CXX11_THREADPOOL_THREAD_POOL_INTERFACE_H
     12 
     13 namespace Eigen {
     14 
     15 // This defines an interface that ThreadPoolDevice can take to use
     16 // custom thread pools underneath.
     17 class ThreadPoolInterface {
     18  public:
     19   virtual void Schedule(std::function<void()> fn) = 0;
     20 
     21   // Returns the number of threads in the pool.
     22   virtual int NumThreads() const = 0;
     23 
     24   // Returns a logical thread index between 0 and NumThreads() - 1 if called
     25   // from one of the threads in the pool. Returns -1 otherwise.
     26   virtual int CurrentThreadId() const = 0;
     27 
     28   virtual ~ThreadPoolInterface() {}
     29 };
     30 
     31 }  // namespace Eigen
     32 
     33 #endif  // EIGEN_CXX11_THREADPOOL_THREAD_POOL_INTERFACE_H
     34