Grok 15.1.0
ExecSingleton Class Reference

Manages Taskflow Executor singleton instance. More...

#include <ThreadPool.hpp>

Static Public Member Functions

static void create (uint32_t numThreads)
 Creates singleton instance.
static tf::Executor & get (void)
 Gets current instance of the Singleton (creates with full hardware concurrency if null)
static size_t num_threads ()
 Gets total number of threads.
static void destroy ()
 Destroys ExecSingleton.
static uint32_t workerId (void)
 Gets worker id for current worker.

Private Member Functions

 ExecSingleton (const ExecSingleton &)=delete
ExecSingletonoperator= (const ExecSingleton &)=delete
 ExecSingleton ()=default
 Constructs an ExecSingleton.

Static Private Attributes

static std::unique_ptr< tf::Executor > instance_ = nullptr
 Taskflow Executor instance.
static std::mutex mutex_
 std::mutex to control access to instance_
static size_t numThreads_
 total number of threads

Detailed Description

Manages Taskflow Executor singleton instance.

Constructor & Destructor Documentation

◆ ExecSingleton() [1/2]

ExecSingleton::ExecSingleton ( const ExecSingleton & )
privatedelete

References ExecSingleton().

Referenced by ExecSingleton(), and operator=().

◆ ExecSingleton() [2/2]

ExecSingleton::ExecSingleton ( )
privatedefault

Constructs an ExecSingleton.

Member Function Documentation

◆ create()

void ExecSingleton::create ( uint32_t numThreads)
inlinestatic

Creates singleton instance.

Parameters
numThreadstotal number of threads including main thread i.e. number of taskflow worker threads + 1

References instance_, mutex_, and numThreads_.

Referenced by get(), and grk_initialize().

◆ destroy()

void ExecSingleton::destroy ( )
inlinestatic

Destroys ExecSingleton.

References instance_, and mutex_.

Referenced by grk_deinitialize().

◆ get()

◆ num_threads()

size_t ExecSingleton::num_threads ( )
inlinestatic

Gets total number of threads.

Returns
size_t number of threads

References numThreads_.

◆ operator=()

ExecSingleton & ExecSingleton::operator= ( const ExecSingleton & )
privatedelete

References ExecSingleton().

◆ workerId()

uint32_t ExecSingleton::workerId ( void )
inlinestatic

Gets worker id for current worker.

Returns
worker id

References get(), and numThreads_.

Member Data Documentation

◆ instance_

std::unique_ptr< tf::Executor > ExecSingleton::instance_ = nullptr
staticprivate

Taskflow Executor instance.

Referenced by create(), destroy(), and get().

◆ mutex_

std::mutex ExecSingleton::mutex_
staticprivate

std::mutex to control access to instance_

Referenced by create(), destroy(), and get().

◆ numThreads_

size_t ExecSingleton::numThreads_
staticprivate

total number of threads

Referenced by create(), num_threads(), and workerId().


The documentation for this class was generated from the following files: