GrPPI  0.2
Generic and Reusable Parallel Pattern Interface
Public Member Functions | List of all members
grppi::thread_registry Class Reference

Thread index table to provide portable natural thread indices. More...

#include <parallel_execution_native.h>

Public Member Functions

 thread_registry () noexcept=default
 
void register_thread () noexcept
 Adds the current thread id in the registry. More...
 
void deregister_thread () noexcept
 Removes current thread id from the registry. More...
 
int current_index () const noexcept
 Integer index for current thread. More...
 

Detailed Description

Thread index table to provide portable natural thread indices.

A thread table provides a simple way to offer thread indices (starting from 0).

When a thread registers itself in the registry, its id is added to the vector of identifiers. When a thread deregisters itself from the registry its entry is modified to contain the empty thread id.

To get an integer index, users may call current_index, which provides the order number of the calling thread in the registry.

Note
This class is thread safe by means of using a spin-lock.

Constructor & Destructor Documentation

grppi::thread_registry::thread_registry ( )
defaultnoexcept

Member Function Documentation

int grppi::thread_registry::current_index ( ) const
inlinenoexcept

Integer index for current thread.

Returns
Integer value with the registration order of current thread.
Precondition
Current thread is registered.
void grppi::thread_registry::deregister_thread ( )
inlinenoexcept

Removes current thread id from the registry.

void grppi::thread_registry::register_thread ( )
inlinenoexcept

Adds the current thread id in the registry.


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