-
Notifications
You must be signed in to change notification settings - Fork 395
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
Add more precise interface handleTimeoutMicroseconds #546
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -322,6 +322,30 @@ int lcm_handle(lcm_t *lcm); | |||||
LCM_EXPORT | ||||||
int lcm_handle_timeout(lcm_t *lcm, int timeout_millis); | ||||||
|
||||||
/** | ||||||
* @brief Wait for and dispatch the next incoming message, up to a time limit. | ||||||
* | ||||||
* This function is equivalent to lcm_handle(), but if no messages are received | ||||||
* and handled by the time @p timeout_micros microseconds elapses, then the | ||||||
* function returns. | ||||||
* | ||||||
* This function largely exists for convenience, and its behavior can be | ||||||
* replicated by using lcm_fileno() and lcm_handle() in conjunction with | ||||||
* select() or poll(). | ||||||
* | ||||||
* New in LCM 1.1.0. | ||||||
* | ||||||
Comment on lines
+336
to
+337
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This method does not exist in LCM 1.1.0
Suggested change
|
||||||
* @param lcm the %LCM object | ||||||
* @param timeout_micros the maximum amount of time to wait for a message, in | ||||||
* microseconds. If 0, then dispatches any available messages and then | ||||||
* returns immediately. Values less than 0 are not allowed. | ||||||
* | ||||||
* @return >0 if a message was handled, 0 if the function timed out, and <0 if | ||||||
* an error occured. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Typo
Suggested change
It also occurs in the |
||||||
*/ | ||||||
LCM_EXPORT | ||||||
int lcm_handle_timeout_us(lcm_t *lcm, int timeout_micros); | ||||||
|
||||||
/** | ||||||
* @brief Adjusts the maximum number of received messages that can be queued up | ||||||
* for a subscription. | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -99,6 +99,15 @@ TEST(LCM_CPP, MemqTimeout) | |
// Invalid timeout specification should result in an error. | ||
EXPECT_GT(0, lcm.handleTimeout(-1)); | ||
|
||
// No messages available. Call should timeout immediately. | ||
EXPECT_EQ(0, lcm.handleTimeoutUs(0)); | ||
|
||
// No messages available. Call should timeout in a few ms. | ||
EXPECT_EQ(0, lcm.handleTimeoutUs(10)); | ||
|
||
// Invalid timeout specification should result in an error. | ||
EXPECT_GT(0, lcm.handleTimeoutUs(-1)); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Underneath this line, there is the following test for // Subscribe to and publish on a channel. Expect that the message gets
// handled with an ample timeout.
bool msg_handled = false;
lcm.subscribeFunction("channel", MemqTimeoutHandler, &msg_handled);
lcm.publish("channel", "", 0);
EXPECT_LT(0, lcm.handleTimeout(10000));
EXPECT_TRUE(msg_handled); Can you duplicate these assertions for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will do it, maybe late! |
||
// Subscribe to and publish on a channel. Expect that the message gets | ||
// handled with an ample timeout. | ||
bool msg_handled = false; | ||
|
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.
This method does not exist in LCM 1.1.0