VTK  9.3.20240327
Classes | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
vtk::detail::smp::vtkSMPThreadPool Class Reference

Internal thread pool implementation used in SMP functions. More...

#include <vtkSMPThreadPool.h>

Classes

class  Proxy
 Proxy class used to submit work to the thread pool. More...
 

Public Member Functions

 vtkSMPThreadPool ()
 
 ~vtkSMPThreadPool ()
 
 vtkSMPThreadPool (const vtkSMPThreadPool &)=delete
 
vtkSMPThreadPooloperator= (const vtkSMPThreadPool &)=delete
 
Proxy AllocateThreads (std::size_t threadCount=0)
 Create a proxy. More...
 
std::size_t GetThreadId () const noexcept
 Get caller proxy thread virtual ID. More...
 
bool IsParallelScope () const noexcept
 Returns true when called from a proxy thread, false otherwise. More...
 
bool GetSingleThread () const
 Returns true for a single proxy thread, false for the others. More...
 
std::size_t ThreadCount () const noexcept
 Returns number of system thread used by the thread pool. More...
 

Static Public Member Functions

static vtkSMPThreadPoolGetInstance ()
 

Static Public Attributes

static constexpr std::size_t ExternalThreadID = 1
 Value returned by GetThreadID when called by a thread that does not belong to the pool. More...
 

Detailed Description

Internal thread pool implementation used in SMP functions.

This class is designed to be a Singleton thread pool, but local pool can be allocated too. This thread pool use a Proxy system that is used to allocate a certain amount of threads from the pool, which enable support for SMP local scopes. You need to have a Proxy to submit job to the pool.

Definition at line 40 of file vtkSMPThreadPool.h.

Constructor & Destructor Documentation

◆ vtkSMPThreadPool() [1/2]

vtk::detail::smp::vtkSMPThreadPool::vtkSMPThreadPool ( )

◆ ~vtkSMPThreadPool()

vtk::detail::smp::vtkSMPThreadPool::~vtkSMPThreadPool ( )

◆ vtkSMPThreadPool() [2/2]

vtk::detail::smp::vtkSMPThreadPool::vtkSMPThreadPool ( const vtkSMPThreadPool )
delete

Member Function Documentation

◆ operator=()

vtkSMPThreadPool& vtk::detail::smp::vtkSMPThreadPool::operator= ( const vtkSMPThreadPool )
delete

◆ AllocateThreads()

Proxy vtk::detail::smp::vtkSMPThreadPool::AllocateThreads ( std::size_t  threadCount = 0)

Create a proxy.

Create a proxy that will use at most threadCount thread of the thread pool. Proxy act as a thread pool on its own, but will in practice submit its work to this pool, this prevent threads to be created every time a SMP function is called.

If the current thread not in the pool, it will create a "top-level" proxy, otherwise it will create a nested proxy. A nested proxy will never use a thread that is already in use by its "parent" proxies to prevent deadlocks. It means that nested paralism may have a more limited amount of threads.

Parameters
threadCountmax amount of thread to use. If 0, uses the number of thread of the pool. If greater than the number of thread of the pool, uses the number of thread of the pool.
Returns
A proxy.

◆ GetThreadId()

std::size_t vtk::detail::smp::vtkSMPThreadPool::GetThreadId ( ) const
noexcept

Get caller proxy thread virtual ID.

This function must be called from a proxy thread. If this function is called from non proxy thread, returns ExternalThreadID. Valid proxy thread virtual ID are always >= 2

◆ IsParallelScope()

bool vtk::detail::smp::vtkSMPThreadPool::IsParallelScope ( ) const
noexcept

Returns true when called from a proxy thread, false otherwise.

◆ GetSingleThread()

bool vtk::detail::smp::vtkSMPThreadPool::GetSingleThread ( ) const

Returns true for a single proxy thread, false for the others.

◆ ThreadCount()

std::size_t vtk::detail::smp::vtkSMPThreadPool::ThreadCount ( ) const
noexcept

Returns number of system thread used by the thread pool.

◆ GetInstance()

static vtkSMPThreadPool& vtk::detail::smp::vtkSMPThreadPool::GetInstance ( )
static

Member Data Documentation

◆ ExternalThreadID

constexpr std::size_t vtk::detail::smp::vtkSMPThreadPool::ExternalThreadID = 1
staticconstexpr

Value returned by GetThreadID when called by a thread that does not belong to the pool.

Definition at line 130 of file vtkSMPThreadPool.h.


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