atomic_fibonacci.hpp
Go to the documentation of this file.
00001 #ifndef ros1_cpp_template_ATOMIC_FIBONACCI_HPP_
00002 #define ros1_cpp_template_ATOMIC_FIBONACCI_HPP_
00003 
00004 #include <string>
00005 #include <mutex>
00006 #include <memory>
00007 #include <atomic>
00008 
00009 namespace ros1_cpptemplate
00010 {
00011 
00015 class AtomicFibonacci
00016 {
00017 public:
00028   AtomicFibonacci(const int& last_number, const int& current_number,
00029                   const int& max_number = 256, const std::string& name = "");
00030 
00034   virtual ~AtomicFibonacci();
00035 
00040   virtual int nextAndLog(const std::string& log_prefix = "");
00041 
00046   virtual int next();
00047 
00054   virtual int nextNext();
00055 
00060   virtual void setMax(const int& value);
00061 
00062 protected:
00066   AtomicFibonacci()
00067   {
00068   }
00069 
00071   mutable std::mutex mutex_;
00072 
00073 private:
00078   int next_();
00079 
00081   int last_number_;
00082 
00084   int current_number_;
00085 
00087   std::atomic<int> max_number_;
00088 
00090   std::string log_prefix_;
00091 };
00092 typedef std::shared_ptr<AtomicFibonacci> AtomicFibonacciPtr;
00093 
00094 }  // namespace
00095 
00096 #endif


ros1_cpptemplate
Author(s): Alexander Reimann
autogenerated on Fri Sep 1 2017 02:23:31