mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 13:27:17 +01:00
eliminate extra copy of vector of SSU2 packets
This commit is contained in:
parent
75b1c144b4
commit
a06cce0aaf
|
@ -391,7 +391,10 @@ namespace transport
|
|||
break;
|
||||
}
|
||||
}
|
||||
GetService ().post (std::bind (&SSU2Server::HandleReceivedPackets, this, packets));
|
||||
GetService ().post ([packets = std::move (packets), this]() mutable
|
||||
{
|
||||
HandleReceivedPackets (std::move (packets));
|
||||
});
|
||||
}
|
||||
else
|
||||
GetService ().post (std::bind (&SSU2Server::HandleReceivedPacket, this, packet));
|
||||
|
@ -435,7 +438,7 @@ namespace transport
|
|||
}
|
||||
}
|
||||
|
||||
void SSU2Server::HandleReceivedPackets (std::vector<Packet *> packets)
|
||||
void SSU2Server::HandleReceivedPackets (std::vector<Packet *>&& packets)
|
||||
{
|
||||
if (m_IsThroughProxy)
|
||||
for (auto& packet: packets)
|
||||
|
@ -443,7 +446,7 @@ namespace transport
|
|||
else
|
||||
for (auto& packet: packets)
|
||||
ProcessNextPacket (packet->buf, packet->len, packet->from);
|
||||
m_PacketsPool.ReleaseMt (packets);
|
||||
m_PacketsPool.ReleaseMt (std::move (packets));
|
||||
if (m_LastSession && m_LastSession->GetState () != eSSU2SessionStateTerminated)
|
||||
m_LastSession->FlushData ();
|
||||
}
|
||||
|
|
|
@ -126,7 +126,7 @@ namespace transport
|
|||
void HandleReceivedFrom (const boost::system::error_code& ecode, size_t bytes_transferred,
|
||||
Packet * packet, boost::asio::ip::udp::socket& socket);
|
||||
void HandleReceivedPacket (Packet * packet);
|
||||
void HandleReceivedPackets (std::vector<Packet *> packets);
|
||||
void HandleReceivedPackets (std::vector<Packet *>&& packets);
|
||||
void ProcessNextPacket (uint8_t * buf, size_t len, const boost::asio::ip::udp::endpoint& senderEndpoint);
|
||||
|
||||
void ScheduleTermination ();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2022, The PurpleI2P Project
|
||||
* Copyright (c) 2013-2024, The PurpleI2P Project
|
||||
*
|
||||
* This file is part of Purple i2pd project and licensed under BSD3
|
||||
*
|
||||
|
@ -132,7 +132,7 @@ namespace util
|
|||
}
|
||||
|
||||
template<template<typename, typename...>class C, typename... R>
|
||||
void ReleaseMt(const C<T *, R...>& c)
|
||||
void ReleaseMt(C<T *, R...>&& c)
|
||||
{
|
||||
std::lock_guard<std::mutex> l(m_Mutex);
|
||||
for (auto& it: c)
|
||||
|
|
Loading…
Reference in a new issue