ApolloAuto/apollo

Blocker in the Reader.

Closed this issue · 7 comments

Each reader has a blocker which has a message list inside. Why use a list if when publish a message push in front and when observe take the message in front?

It is a queue and not a list, What do you mean by list

BlockerAttr attr_;
MessageQueue observed_msg_queue_;
MessageQueue published_msg_queue_;
mutable std::mutex msg_mutex_;

What policy is adopted in this queue?

it's a queue, without any priority.

I think there is no way to control the priority of the message for now, only the priority of the coroutine?

What policy is adopted in this queue?

NO policy, just FIFO.

Ok, but I have a question. For example in the code below, in the function called at line 282 happens observed_msg_queue_ = published_msg_queue_; and in the function called at the line 283

if (observed_msg_queue_.empty()) {
    return dummy_msg_;
  }
  return *observed_msg_queue_.front();

Why I take the element in front of the queue and not in the back?

bool ControlComponent::Proc() {
const auto start_time = Clock::Now();
chassis_reader_->Observe();
const auto &chassis_msg = chassis_reader_->GetLatestObserved();
if (chassis_msg == nullptr) {
AERROR << "Chassis msg is not ready!";
return false;
}
OnChassis(chassis_msg);

I was wrong before, this is indeed a list.

  using MessageQueue = std::list<MessagePtr>;

I search the method, seems all the modules just used GetLatestObserved. Then only one size buffer is enough, if we don't need old messages.

Messages will put in front of the list, and when the buffer is full, it will pop at the back. So the latest message will always in the front.

Closed due to inactivity. If the problem persists, pls feel free to reopen it or create a new one and refer to it.