#include <atomic_fibonacci.hpp>
Class which returns the next (or next next) Fibonacci number thread safe
Definition at line 15 of file atomic_fibonacci.hpp.
ros1_cpptemplate::AtomicFibonacci::AtomicFibonacci |
( |
const int & |
last_number, |
|
|
const int & |
current_number, |
|
|
const int & |
max_number = 256 , |
|
|
const std::string & |
name = "" |
|
) |
| |
Constructor If max_number
is reached the sqeuence is reset to (0, 1) making last_number_
0 and current_number_
1
- Parameters
-
last_number | Initial last Fibonacci number |
current_number | Initial current Fibonacci number |
max_number | max_number after the sequence gets reset to (0, 1) |
name | Name used for logging prefix |
Definition at line 11 of file atomic_fibonacci.cpp.
ros1_cpptemplate::AtomicFibonacci::~AtomicFibonacci |
( |
| ) |
|
|
virtual |
ros1_cpptemplate::AtomicFibonacci::AtomicFibonacci |
( |
| ) |
|
|
inlineprotected |
int ros1_cpptemplate::AtomicFibonacci::next |
( |
| ) |
|
|
virtual |
Get the next Fibonacci number
- Returns
- Next Fibonacci number
Definition at line 43 of file atomic_fibonacci.cpp.
int ros1_cpptemplate::AtomicFibonacci::next_ |
( |
| ) |
|
|
private |
Get the next Fibonacci number without locking
- Returns
- Next Fibonacci number
Definition at line 56 of file atomic_fibonacci.cpp.
int ros1_cpptemplate::AtomicFibonacci::nextAndLog |
( |
const std::string & |
log_prefix = "" | ) |
|
|
virtual |
Get the next Fibonacci number and log it
- Returns
- Next Fibonacci number
Definition at line 35 of file atomic_fibonacci.cpp.
int ros1_cpptemplate::AtomicFibonacci::nextNext |
( |
| ) |
|
|
virtual |
Get the Fibonacci number after the next Fibonacci number This advances the sequence of the internal state by two steps (bascially it calls next() twice)
- Returns
- Next next Fibonacci number
Definition at line 49 of file atomic_fibonacci.cpp.
void ros1_cpptemplate::AtomicFibonacci::setMax |
( |
const int & |
value | ) |
|
|
virtual |
Set the max Fibonacci number before reset to (0, 1)
- Parameters
-
Definition at line 73 of file atomic_fibonacci.cpp.
int ros1_cpptemplate::AtomicFibonacci::current_number_ |
|
private |
int ros1_cpptemplate::AtomicFibonacci::last_number_ |
|
private |
std::string ros1_cpptemplate::AtomicFibonacci::log_prefix_ |
|
private |
std::atomic<int> ros1_cpptemplate::AtomicFibonacci::max_number_ |
|
private |
std::mutex ros1_cpptemplate::AtomicFibonacci::mutex_ |
|
mutableprotected |
The documentation for this class was generated from the following files: