21#include <unordered_map>
40 static void create(
size_t numThreads)
42 std::lock_guard<std::mutex> lock(
mutex_);
43 numThreads = numThreads ? numThreads : std::thread::hardware_concurrency();
54 static tf::Executor&
get(
void)
56 std::lock_guard<std::mutex> lock(
mutex_);
75 std::lock_guard<std::mutex> lock(
mutex_);
84 std::lock_guard<std::mutex> lock(
mutex_);
96 auto id =
get().this_worker_id();
97 return (
id >= 0) ? (uint32_t)
id : 0u;
static size_t num_threads()
Gets total number of threads (including driver thread).
Definition TFSingleton.h:73
static std::unique_ptr< tf::Executor > instance_
Taskflow Executor instance.
Definition TFSingleton.h:112
TFSingleton(const TFSingleton &)=delete
static std::mutex mutex_
std::mutex to control access to instance_
Definition TFSingleton.h:117
static void create(size_t numThreads)
Creates singleton instance.
Definition TFSingleton.h:40
static uint32_t workerId(void)
Gets worker id for current worker.
Definition TFSingleton.h:94
TFSingleton()=default
Constructs an TFSingleton.
TFSingleton & operator=(const TFSingleton &)=delete
static void destroy()
Destroys TFSingleton.
Definition TFSingleton.h:82
static size_t numThreads_
total number of threads
Definition TFSingleton.h:122
static tf::Executor & get(void)
Gets current instance of the Singleton (creates with full hardware concurrency if null).
Definition TFSingleton.h:54