Skip to content

Commit

Permalink
fix: set_spin_duration_based_on_params
Browse files Browse the repository at this point in the history
Signed-off-by: atsushi421 <atsushi.yano.2@tier4.jp>
  • Loading branch information
atsushi421 committed Feb 27, 2025
1 parent 15a7533 commit 8994515
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@ class MultiThreadedAgnocastExecutorNoStarvationTest
private:
void set_spin_duration_based_on_params(const int agnocast_next_exec_timeout_ms)
{
std::chrono::seconds buffer = std::chrono::seconds(3); // Rough value
std::chrono::seconds buffer = std::chrono::seconds(1); // Rough value
spin_duration_ =
std::chrono::seconds(
agnocast_next_exec_timeout_ms * (NUM_AGNOCAST_SUB_CBS + NUM_AGNOCAST_CBS_TO_BE_ADDED) /
1000 / NUMBER_OF_AGNOCAST_THREADS) +
std::max(
std::chrono::seconds(
agnocast_next_exec_timeout_ms * (NUM_AGNOCAST_SUB_CBS + NUM_AGNOCAST_CBS_TO_BE_ADDED) /
1000 / NUMBER_OF_AGNOCAST_THREADS),
std::chrono::duration_cast<std::chrono::seconds>(
PUB_PERIOD * NUM_AGNOCAST_CBS_TO_BE_ADDED)) +
buffer;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@ class SingleThreadedAgnocastExecutorNoStarvationTest : public ::testing::TestWit
private:
void set_spin_duration_based_on_params(const int next_exec_timeout_ms)
{
std::chrono::seconds buffer = std::chrono::seconds(3); // Rough value
std::chrono::seconds buffer = std::chrono::seconds(1); // Rough value
spin_duration_ =
std::chrono::seconds(
next_exec_timeout_ms * (NUM_AGNOCAST_SUB_CBS + NUM_AGNOCAST_CBS_TO_BE_ADDED) / 1000) +
std::max(
std::chrono::seconds(
next_exec_timeout_ms * (NUM_AGNOCAST_SUB_CBS + NUM_AGNOCAST_CBS_TO_BE_ADDED) / 1000),
std::chrono::duration_cast<std::chrono::seconds>(
PUB_PERIOD * NUM_AGNOCAST_CBS_TO_BE_ADDED)) +
buffer;
}

Expand Down

0 comments on commit 8994515

Please sign in to comment.