Skip to content

Commit

Permalink
[C++] std::forward fragment handlers to avoid unnecessary copies (#1405)
Browse files Browse the repository at this point in the history
Co-authored-by: Joan-Roch Sala <joan@augn.net>
  • Loading branch information
jrsala-auguration and Joan-Roch Sala authored Mar 1, 2023
1 parent 562f048 commit f49a348
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion aeron-client/src/main/cpp/Image.h
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ class Image
AtomicBuffer &termBuffer = m_termBuffers[index];
TermReader::ReadOutcome outcome{};

TermReader::read(outcome, termBuffer, offset, fragmentHandler, fragmentLimit, m_header, m_exceptionHandler);
TermReader::read(outcome, termBuffer, offset, std::forward<F>(fragmentHandler), fragmentLimit, m_header, m_exceptionHandler);

const std::int64_t newPosition = position + (outcome.offset - offset);
if (newPosition > position)
Expand Down
10 changes: 5 additions & 5 deletions aeron-client/src/main/cpp/Subscription.h
Original file line number Diff line number Diff line change
Expand Up @@ -221,12 +221,12 @@ class CLIENT_EXPORT Subscription

for (std::size_t i = startingIndex; i < length && fragmentsRead < fragmentLimit; i++)
{
fragmentsRead += imageArray[i]->poll(fragmentHandler, fragmentLimit - fragmentsRead);
fragmentsRead += imageArray[i]->poll(std::forward<F>(fragmentHandler), fragmentLimit - fragmentsRead);
}

for (std::size_t i = 0; i < startingIndex && fragmentsRead < fragmentLimit; i++)
{
fragmentsRead += imageArray[i]->poll(fragmentHandler, fragmentLimit - fragmentsRead);
fragmentsRead += imageArray[i]->poll(std::forward<F>(fragmentHandler), fragmentLimit - fragmentsRead);
}

return fragmentsRead;
Expand Down Expand Up @@ -263,12 +263,12 @@ class CLIENT_EXPORT Subscription

for (std::size_t i = startingIndex; i < length && fragmentsRead < fragmentLimit; i++)
{
fragmentsRead += imageArray[i]->controlledPoll(fragmentHandler, fragmentLimit - fragmentsRead);
fragmentsRead += imageArray[i]->controlledPoll(std::forward<F>(fragmentHandler), fragmentLimit - fragmentsRead);
}

for (std::size_t i = 0; i < startingIndex && fragmentsRead < fragmentLimit; i++)
{
fragmentsRead += imageArray[i]->controlledPoll(fragmentHandler, fragmentLimit - fragmentsRead);
fragmentsRead += imageArray[i]->controlledPoll(std::forward<F>(fragmentHandler), fragmentLimit - fragmentsRead);
}

return fragmentsRead;
Expand All @@ -291,7 +291,7 @@ class CLIENT_EXPORT Subscription

for (std::size_t i = 0; i < length; i++)
{
bytesConsumed += imageArray[i]->blockPoll(blockHandler, blockLengthLimit);
bytesConsumed += imageArray[i]->blockPoll(std::forward<F>(blockHandler), blockLengthLimit);
}

return bytesConsumed;
Expand Down

0 comments on commit f49a348

Please sign in to comment.