Open Junxia0Wang opened 3 months ago
ConcurrentQueue define as : moodycamel::ConcurrentQueue<uint64_t> clocks_;
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.
Well, what value is first enqueued? How are you inspecting the first value dequeued?
ConcurrentQueue define as :
moodycamel::ConcurrentQueue<uint64_t> clocks_;
Enqueue thread:
Dequeue thread:
First clock_time get by try_dequeue always is 1.