VTK
9.3.20231204
|
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 | |
vtkSMPThreadPool & | operator= (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 vtkSMPThreadPool & | GetInstance () |
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... | |
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.
vtk::detail::smp::vtkSMPThreadPool::vtkSMPThreadPool | ( | ) |
vtk::detail::smp::vtkSMPThreadPool::~vtkSMPThreadPool | ( | ) |
|
delete |
|
delete |
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.
threadCount | max 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. |
|
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
|
noexcept |
Returns true when called from a proxy thread, false otherwise.
bool vtk::detail::smp::vtkSMPThreadPool::GetSingleThread | ( | ) | const |
Returns true for a single proxy thread, false for the others.
|
noexcept |
Returns number of system thread used by the thread pool.
|
static |
|
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.