Geogram
Version 1.9.1
A programming library of geometric algorithms
|
Platform-independent base class for running concurrent threads. More...
#include <geogram/basic/process.h>
Public Member Functions | |
virtual void | run_threads (ThreadGroup &threads) |
Runs a group of Threads. More... | |
virtual index_t | maximum_concurrent_threads ()=0 |
Gets the maximum number of possible concurrent threads. More... | |
Public Member Functions inherited from GEO::Counted | |
void | ref () const |
Increments the reference count. More... | |
void | unref () const |
Decrements the reference count. More... | |
bool | is_shared () const |
Check if the object is shared. More... | |
int | nb_refs () const |
Gets the number of references that point to this object. More... | |
Protected Member Functions | |
virtual void | run_concurrent_threads (ThreadGroup &threads, index_t max_threads)=0 |
Runs a group of Threads concurrently. More... | |
~ThreadManager () override | |
Protected Member Functions inherited from GEO::Counted | |
Counted () | |
Creates a reference counted object. More... | |
virtual | ~Counted () |
Destroys a reference counted object. More... | |
Static Protected Member Functions | |
static void | set_thread_id (Thread *thread, index_t id) |
Sets the id of a thread. More... | |
static void | set_current_thread (Thread *thread) |
Specifies the current instance, used by current(). More... | |
Additional Inherited Members | |
Static Public Member Functions inherited from GEO::Counted | |
static void | ref (const Counted *counted) |
Increments the reference count. More... | |
static void | unref (const Counted *counted) |
Decrements the reference count. More... | |
Platform-independent base class for running concurrent threads.
The ThreadManager manager provides a platform-independent abstract interface for running concurrent Threads and managing critical sections.
The ThreadManager is derived in multiple platform-specific or technology-specific implementations.
Platform-specific implementations:
Technology-specific implementations:
Which ThreadManager to use is determined at runtime by Process::initialize() according to the current platform or the current available technology.
|
overrideprotected |
ThreadManager destructor
|
pure virtual |
Gets the maximum number of possible concurrent threads.
Implemented in GEO::MonoThreadingThreadManager.
|
protectedpure virtual |
Runs a group of Threads concurrently.
This start the concurrent execution of the threads contained in vector threads
, using the given number of threads max_threads
. The execution terminates when the last thread terminates.
[in] | threads | the vector of threads to be executed. |
[in] | max_threads | maximum number of threads allowed for this execution. It is always greater than one |
Implemented in GEO::MonoThreadingThreadManager.
|
virtual |
Runs a group of Threads.
This start the execution of the threads contained in vector threads
.
If the threads cannot be executed in a concurrent environment (multi-threading is disabled or the number of maximum threads is 1), then the threads are executed sequentially. Otherwise the function run_concurrent_threads() is called to execute the threads concurrently. The execution terminates when the last thread terminates.
[in] | threads | the vector of threads to be executed. |
|
inlinestaticprotected |
Specifies the current instance, used by current().
Stores the specified thread in the thread-local-storage static variable so that current() can retrieve it. Should be called by the ThreadManager right before launching the threads.
[in] | thread | a pointer to the thread currently executed |