-
Notifications
You must be signed in to change notification settings - Fork 5
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
Allow multiple messages to be scheduled with the same ID if the interval is set to 0 #30
Conversation
m_sendQueue.push_back(detail::CANThreadSendQueueElement(msg, timeIntervalMs)); | ||
} else { | ||
// We don't want to replace elements with zero as the interval. Those should be guaranteed to be sent | ||
detail::CANThreadSendQueueElement* existing = findFirstMatchingIdWithNonZeroInterval(msg.GetMessageId()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After this change, calling with (data1, 0), then immediately calling with (data2, 5) will ensure that data1 is always sent once, then data2 is sent every 5 milliseconds.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, more practically, calling with (data_i, 0) repeatedly will ensure all the data actually gets sent.
Nice find! |
@@ -84,20 +84,41 @@ class DriverDeviceThread { | |||
return nullptr; // If no matching element found | |||
} | |||
|
|||
detail::CANThreadSendQueueElement* findFirstMatchingIdWithNonZeroInterval(int targetId) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like findFirstMatchingId()
can be deleted
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deleted
Our current contract for the interval is as follows:
A caller that provides 0 multiple times can reasonably assume that every message is sent, but this was not the case previously. Only one message could be scheduled at a time with a given ID.