Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First try_queue return 1 always #394

Open
Junxia0Wang opened this issue Jul 23, 2024 · 1 comment
Open

First try_queue return 1 always #394

Junxia0Wang opened this issue Jul 23, 2024 · 1 comment

Comments

@Junxia0Wang
Copy link

Junxia0Wang commented Jul 23, 2024

ConcurrentQueue define as :
moodycamel::ConcurrentQueue<uint64_t> clocks_;

Enqueue thread:

  while (curr_clock_time < end_clock_time && !stop_) {
    SINFO("ENQUEUE CLOCK: {}", curr_clock_time);
    while (!clocks_.try_enqueue(curr_clock_time)) {
      std::this_thread::sleep_for(std::chrono::nanoseconds(options_.precision));
    }
    curr_clock_time += step;
  }

Dequeue thread:

while (timestamp > clock_time && clocks_.size_approx() > 0) {
      auto msg = rosgraph_msgs::msg::Clock();
      msg.clock.sec = static_cast<int32_t>(clock_time / 1e9);
      msg.clock.nanosec = static_cast<uint32_t>(clock_time % static_cast<uint64_t>(1e9));
      SINFO("DEQUEUE CLOCK: {}", clock_time);
      clock_writer_->publish(msg);
      while (!clocks_.try_dequeue(clock_time) && clocks_.size_approx() > 0) {
        std::this_thread::sleep_for(std::chrono::nanoseconds(options_.precision));
      }
    }

First clock_time get by try_dequeue always is 1.

@cameron314
Copy link
Owner

Well, what value is first enqueued? How are you inspecting the first value dequeued?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants