@@ -25,7 +25,8 @@ limitations under the License.
2525namespace Lotus {
2626namespace thread {
2727
28- struct EigenEnvironment {
28+ class EigenEnvironment {
29+ public:
2930 typedef Thread EnvThread;
3031
3132 struct TaskImpl {
@@ -38,16 +39,12 @@ struct EigenEnvironment {
3839 std::unique_ptr<TaskImpl> f;
3940 };
4041
41- Env* const env_;
42- const ThreadOptions thread_options_;
43- const std::string name_;
44-
45- EigenEnvironment (Env* env, const ThreadOptions& thread_options,
42+ EigenEnvironment (const Env& env, const ThreadOptions& thread_options,
4643 const std::string& name)
4744 : env_(env), thread_options_(thread_options), name_(name) {}
4845
4946 EnvThread* CreateThread (std::function<void ()> f) {
50- return env_-> StartThread (thread_options_, name_, [=]() {
47+ return env_. StartThread (thread_options_, name_, [=]() {
5148 // TODO
5249 // Set the processor flag to flush denormals to zero.
5350 // port::ScopedFlushDenormal flush;
@@ -85,24 +82,29 @@ struct EigenEnvironment {
8582 t.f ->f ();
8683 }
8784 }
85+
86+ private:
87+ const Env& env_;
88+ const ThreadOptions thread_options_;
89+ const std::string name_;
8890};
8991
9092struct ThreadPool ::Impl : Eigen::ThreadPoolTempl<EigenEnvironment> {
91- Impl (Env* env, const ThreadOptions& thread_options, const std::string& name,
93+ Impl (const Env& env, const ThreadOptions& thread_options, const std::string& name,
9294 int num_threads, bool low_latency_hint)
9395 : Eigen::ThreadPoolTempl<EigenEnvironment>(
9496 num_threads, low_latency_hint,
9597 EigenEnvironment (env, thread_options, name)) {}
9698};
9799
98- ThreadPool::ThreadPool (Env* env, const std::string& name, int num_threads)
100+ ThreadPool::ThreadPool (const Env& env, const std::string& name, int num_threads)
99101 : ThreadPool(env, ThreadOptions(), name, num_threads, true ) {}
100102
101- ThreadPool::ThreadPool (Env* env, const ThreadOptions& thread_options,
103+ ThreadPool::ThreadPool (const Env& env, const ThreadOptions& thread_options,
102104 const std::string& name, int num_threads)
103105 : ThreadPool(env, thread_options, name, num_threads, true ) {}
104106
105- ThreadPool::ThreadPool (Env* env, const ThreadOptions& thread_options,
107+ ThreadPool::ThreadPool (const Env& env, const ThreadOptions& thread_options,
106108 const std::string& name, int num_threads,
107109 bool low_latency_hint) {
108110 LOTUS_ENFORCE (num_threads >= 1 );
0 commit comments