NebulaStream  0.6.213
NebulaStream is a data and application management framework for the internet of things
NES::Runtime::ThreadPool Class Reference

the tread pool handles the dynamic scheduling of tasks during Runtime @Limitations More...

#include <ThreadPool.hpp>

Public Member Functions

 ThreadPool (WorkerId nodeId, QueryManagerPtr queryManager, uint32_t numThreads, std::vector< BufferManagerPtr > bufferManagers, uint64_t numberOfBuffersPerWorker, HardwareManagerPtr hardwareManager, std::vector< uint64_t > workerPinningPositionList)
 default constructor More...
 
 ~ThreadPool ()
 default destructor More...
 
bool stop ()
 stop the Thread pool 1.) check if thread pool is already running, More...
 
bool isRunning () const
 
bool start (const std::vector< uint64_t > threadToQueueMapping={})
 start the Thread pool 1.) check if thread pool is already running, More...
 
void runningRoutine (WorkerContext &&workerContext)
 running routine of threads, in this routine, threads repeatedly execute the following steps 1.) Check if running is still true 2.) If yes, request work from query manager (blocking until tasks get available) 3.) If task is valid, execute the task and completeWork 4.) Repeat More...
 
uint32_t getNumberOfThreads () const
 get the current number of threads in thread pool More...
 

Detailed Description

the tread pool handles the dynamic scheduling of tasks during Runtime @Limitations

  • threads are not pinned to cores
  • not using std::thread::hardware_concurrency() to run with max threads
  • no statistics are gathered

Constructor & Destructor Documentation

◆ ThreadPool()

NES::Runtime::ThreadPool::ThreadPool ( WorkerId  nodeId,
QueryManagerPtr  queryManager,
uint32_t  numThreads,
std::vector< BufferManagerPtr bufferManagers,
uint64_t  numberOfBuffersPerWorker,
HardwareManagerPtr  hardwareManager,
std::vector< uint64_t >  workerPinningPositionList 
)
explicit

default constructor

Parameters
nodeIdthe id of this node
queryManager
numberof threads to use
sourcePinningPositionList,alist of where to pin the

◆ ~ThreadPool()

NES::Runtime::ThreadPool::~ThreadPool ( )

default destructor

References NES_DEBUG, and stop().

Here is the call graph for this function:

Member Function Documentation

◆ getNumberOfThreads()

uint32_t NES::Runtime::ThreadPool::getNumberOfThreads ( ) const

get the current number of threads in thread pool

Returns
number of current threads

◆ isRunning()

bool NES::Runtime::ThreadPool::isRunning ( ) const
inline

◆ runningRoutine()

void NES::Runtime::ThreadPool::runningRoutine ( WorkerContext &&  workerContext)

running routine of threads, in this routine, threads repeatedly execute the following steps 1.) Check if running is still true 2.) If yes, request work from query manager (blocking until tasks get available) 3.) If task is valid, execute the task and completeWork 4.) Repeat

References NES::AllFinished, NES::Error, NES::Finished, NES::TaskExecutionException::getExecutable(), NES_ASSERT, NES_DEBUG, NES_ERROR, NES_THROW_RUNTIME_ERROR, NES::Ok, and NES::Exceptions::RuntimeException::what().

Referenced by start().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ start()

bool NES::Runtime::ThreadPool::start ( const std::vector< uint64_t >  threadToQueueMapping = {})

start the Thread pool 1.) check if thread pool is already running,

  • if yes, return false
  • if not set to running to true 2.) spawn n threads and bind them to the running routine (routine that probes queue for runnable tasks)
    Returns
    indicate if start succeed

References NES::Runtime::NesThread::getId(), NES_ASSERT, NES_DEBUG, NES_ERROR, NES_WARNING, runningRoutine(), and NES::setThreadName().

Here is the call graph for this function:

◆ stop()

bool NES::Runtime::ThreadPool::stop ( )

stop the Thread pool 1.) check if thread pool is already running,

  • if no, return false
  • if yes set to running to false 2.) waking up all sleeping threads, during their next getWork, they will recognize that the execution should terminate and exit running routine 3.) join all threads, i.e., wait till all threads return
    Returns
    indicate if stop succeed

References NES_DEBUG.

Referenced by ~ThreadPool().

Here is the caller graph for this function:

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