27 bool log_buffer_full =
true);
53 virtual void onValueReceived(T val);
61 void continuouslyPullValuesFromBuffer();
70 virtual std::optional<T> getNextValue(
const Duration& max_wait_time);
73 std::mutex in_destructor_mutex;
78 const Duration IN_DESTRUCTOR_CHECK_PERIOD;
82 std::thread pull_from_buffer_thread;
87 :
Observer<T>(buffer_size, log_buffer_full),
89 IN_DESTRUCTOR_CHECK_PERIOD(
Duration::fromSeconds(0.1))
91 pull_from_buffer_thread = std::thread(
92 boost::bind(&ThreadedObserver::continuouslyPullValuesFromBuffer,
this));
107 in_destructor_mutex.unlock();
108 std::optional<T> new_val;
110 new_val = this->getNextValue(IN_DESTRUCTOR_CHECK_PERIOD);
114 onValueReceived(*new_val);
117 in_destructor_mutex.lock();
118 }
while (!in_destructor);
125 in_destructor_mutex.lock();
126 in_destructor =
true;
127 in_destructor_mutex.unlock();
131 pull_from_buffer_thread.join();