atomic_fibonacci.hpp
Go to the documentation of this file.
1 #ifndef ros1_cpp_template_ATOMIC_FIBONACCI_HPP_
2 #define ros1_cpp_template_ATOMIC_FIBONACCI_HPP_
3 
4 #include <string>
5 #include <mutex>
6 #include <memory>
7 #include <atomic>
8 
9 namespace ros1_cpptemplate
10 {
11 
16 {
17 public:
28  AtomicFibonacci(const int& last_number, const int& current_number,
29  const int& max_number = 256, const std::string& name = "");
30 
34  virtual ~AtomicFibonacci();
35 
40  virtual int nextAndLog(const std::string& log_prefix = "");
41 
46  virtual int next();
47 
54  virtual int nextNext();
55 
60  virtual void setMax(const int& value);
61 
62 protected:
67  {
68  }
69 
71  mutable std::mutex mutex_;
72 
73 private:
78  int next_();
79 
82 
85 
87  std::atomic<int> max_number_;
88 
90  std::string log_prefix_;
91 };
92 typedef std::shared_ptr<AtomicFibonacci> AtomicFibonacciPtr;
93 
94 } // namespace
95 
96 #endif
int last_number_
Last Fibonacci number.
std::shared_ptr< AtomicFibonacci > AtomicFibonacciPtr
virtual int nextAndLog(const std::string &log_prefix="")
virtual void setMax(const int &value)
int current_number_
Current Fibonacci number.
std::mutex mutex_
Mutex for locking.
std::atomic< int > max_number_
Max Fibonacci number before reseting the sequence.
std::string log_prefix_
Log prefix.


ros1_cpptemplate
Author(s): Alexander Reimann
autogenerated on Sat Sep 2 2017 02:37:58