From 6eea4777b45942c1ad2b1662ae9a22efdb2b6227 Mon Sep 17 00:00:00 2001 From: Andreas Greimel Date: Mon, 10 Sep 2018 16:26:13 +0200 Subject: [PATCH] GH-70 Harmonize storage_loading_future variable --- rosbag2/src/rosbag2/player.cpp | 11 ++++++----- rosbag2/src/rosbag2/player.hpp | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/rosbag2/src/rosbag2/player.cpp b/rosbag2/src/rosbag2/player.cpp index b16a6465ec..80bc16f634 100644 --- a/rosbag2/src/rosbag2/player.cpp +++ b/rosbag2/src/rosbag2/player.cpp @@ -50,19 +50,20 @@ void Player::play(Rosbag2PlayOptions options) { prepare_publishers(); - auto db_read_future = std::async(std::launch::async, + auto storage_loading_future = std::async(std::launch::async, [this, options]() {load_storage_content(options);}); - wait_for_filled_queue(options, db_read_future); + wait_for_filled_queue(options, storage_loading_future); - play_messages_from_queue(std::move(db_read_future)); + play_messages_from_queue(std::move(storage_loading_future)); } void Player::wait_for_filled_queue( - const Rosbag2PlayOptions & options, const std::future & db_read_future) const + const Rosbag2PlayOptions & options, const std::future & storage_loading_future) const { while ( - message_queue_.size_approx() < options.queue_buffer_length_ && is_pending(db_read_future)) + message_queue_.size_approx() < options.queue_buffer_length_ && + is_pending(storage_loading_future)) { std::this_thread::sleep_for(std::chrono::milliseconds(100)); } diff --git a/rosbag2/src/rosbag2/player.hpp b/rosbag2/src/rosbag2/player.hpp index 866c812730..43a81db59d 100644 --- a/rosbag2/src/rosbag2/player.hpp +++ b/rosbag2/src/rosbag2/player.hpp @@ -46,7 +46,7 @@ class Player void load_storage_content(const Rosbag2PlayOptions & options); void enqueue_up_to_boundary(const TimePoint & time_first_message, uint64_t boundary); void wait_for_filled_queue( - const Rosbag2PlayOptions & options, const std::future & db_read_future) const; + const Rosbag2PlayOptions & options, const std::future & storage_loading_future) const; void play_messages_from_queue(std::future storage_loading_future); void prepare_publishers();