|
Peano
|
Simple rank-global enumerator. More...
#include <Enumerator.h>

Public Member Functions | |
| Enumerator (int max=std::numeric_limits< int >::max() -2) | |
| void | reset () |
| Complete reset, which basically eliminates all the active numbers. | |
| void | setMax (int max) |
| int | getNumber () |
| Return unique number. | |
| void | releaseNumber (int value) |
| Free a number. | |
| int | size () const |
| Number of numbers handed out so far. | |
| std::string | toString () const |
Static Public Attributes | |
| static constexpr int | NoNumber = -1 |
Private Attributes | |
| tarch::multicore::BooleanSemaphore | _semaphore |
| std::set< int > | _activeNumbers |
| int | _max |
| int | _lastNumberHandedOut |
Static Private Attributes | |
| static tarch::logging::Log | _log |
Simple rank-global enumerator.
Very simple utility class to build up a global set of numbers on a rank. Is used in various places to create task numbers for example or to enumerate all vertices and cells properly.
The object is thread-safe, i.e. all modifiers are protected via a semaphore.
It ensures that no number is handed out twice, by maintaining a set of _activeNumbers.
Definition at line 28 of file Enumerator.h.
| tarch::Enumerator::Enumerator | ( | int | max = std::numeric_limits< int >::max() -2 | ) |
| int tarch::Enumerator::getNumber | ( | ) |
Return unique number.
Returns a unique non-zero number which is not yet used anywhere else on this rank. The number is positive or zero.
| void tarch::Enumerator::releaseNumber | ( | int | value | ) |
Free a number.
number has to be the result of a previous getNumber() call. We had the situation where enclave task numbers became really big as we just increment _lastNumberHandedOut in getNumber(). So what I do is that I reduce _lastNumberHandedOut by half if value is too big. This way, we at least scan only half of the overall number range that we might have at our disposal.
| value | The number that we want to release. If you pass in NoNumber, then nothing happens. |
| void tarch::Enumerator::reset | ( | ) |
Complete reset, which basically eliminates all the active numbers.
| void tarch::Enumerator::setMax | ( | int | max | ) |
| int tarch::Enumerator::size | ( | ) | const |
Number of numbers handed out so far.
Referenced by tarch.plotter.api.input.Patch.Patch::__repr__().

| std::string tarch::Enumerator::toString | ( | ) | const |
|
private |
Definition at line 75 of file Enumerator.h.
|
private |
Definition at line 77 of file Enumerator.h.
|
staticprivate |
Definition at line 72 of file Enumerator.h.
|
private |
Definition at line 76 of file Enumerator.h.
|
private |
Definition at line 74 of file Enumerator.h.
|
staticconstexpr |
Definition at line 30 of file Enumerator.h.