ThreadPoolInterface.h
00001 // This file is part of Eigen, a lightweight C++ template library
00002 // for linear algebra.
00003 //
00004 // Copyright (C) 2014 Benoit Steiner <benoit.steiner.goog@gmail.com>
00005 //
00006 // This Source Code Form is subject to the terms of the Mozilla
00007 // Public License v. 2.0. If a copy of the MPL was not distributed
00008 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
00009 
00010 #ifndef EIGEN_CXX11_THREADPOOL_THREAD_POOL_INTERFACE_H
00011 #define EIGEN_CXX11_THREADPOOL_THREAD_POOL_INTERFACE_H
00012 
00013 namespace Eigen {
00014 
00015 // This defines an interface that ThreadPoolDevice can take to use
00016 // custom thread pools underneath.
00017 class ThreadPoolInterface {
00018  public:
00019   virtual void Schedule(std::function<void()> fn) = 0;
00020 
00021   // Returns the number of threads in the pool.
00022   virtual int NumThreads() const = 0;
00023 
00024   // Returns a logical thread index between 0 and NumThreads() - 1 if called
00025   // from one of the threads in the pool. Returns -1 otherwise.
00026   virtual int CurrentThreadId() const = 0;
00027 
00028   virtual ~ThreadPoolInterface() {}
00029 };
00030 
00031 }  // namespace Eigen
00032 
00033 #endif  // EIGEN_CXX11_THREADPOOL_THREAD_POOL_INTERFACE_H
 All Classes Functions Variables Typedefs Enumerator