Grok  9.7.5
ThreadPool.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016-2022 Grok Image Compression Inc.
3  *
4  * This source code is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Affero General Public License, version 3,
6  * as published by the Free Software Foundation.
7  *
8  * This source code is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU Affero General Public License for more details.
12  *
13  * You should have received a copy of the GNU Affero General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  */
17 
18 #pragma once
19 
20 #ifndef _MSC_VER
21 #pragma GCC diagnostic push
22 #pragma GCC diagnostic ignored "-Wsign-conversion"
23 #ifdef __clang__
24 #pragma GCC diagnostic ignored "-Wimplicit-int-float-conversion"
25 #endif
26 #endif
27 #include <taskflow/taskflow.hpp>
28 #ifndef _MSC_VER
29 #pragma GCC diagnostic pop
30 #endif
31 
33 {
34  public:
35  static tf::Executor* instance(uint32_t numthreads)
36  {
37  static tf::Executor singleton(numthreads ? numthreads
38  : std::thread::hardware_concurrency());
39 
40  return &singleton;
41  }
42  static tf::Executor* get()
43  {
44  return instance(0);
45  }
46  static void release()
47  {
48  get()->shutdown();
49  }
50 };
Definition: ThreadPool.hpp:33
static tf::Executor * instance(uint32_t numthreads)
Definition: ThreadPool.hpp:35
static tf::Executor * get()
Definition: ThreadPool.hpp:42
static void release()
Definition: ThreadPool.hpp:46