Рефакторинг обработки наблюдаемых областей

This commit is contained in:
2025-03-02 21:44:16 +06:00
parent a007aa85d0
commit 00d0eec88f
15 changed files with 512 additions and 381 deletions

View File

@@ -31,14 +31,15 @@ AsyncSocket::~AsyncSocket() {
if(SendPackets.Context)
SendPackets.Context->NeedShutdown = true;
boost::lock_guard lock(SendPackets.Mtx);
{
boost::lock_guard lock(SendPackets.Mtx);
SendPackets.SenderGuard.cancel();
WorkDeadline.cancel();
}
if(Socket.is_open())
try { Socket.close(); } catch(...) {}
SendPackets.SenderGuard.cancel();
WorkDeadline.cancel();
}
void AsyncSocket::pushPackets(std::vector<Packet> *simplePackets, std::vector<SmartPacket> *smartPackets) {
@@ -49,6 +50,7 @@ void AsyncSocket::pushPackets(std::vector<Packet> *simplePackets, std::vector<Sm
|| SendPackets.SmartBuffer.size() + (smartPackets ? smartPackets->size() : 0) >= MAX_SMART_PACKETS
|| SendPackets.SizeInQueue >= MAX_PACKETS_SIZE_IN_WAIT))
{
lock.unlock();
try { Socket.close(); } catch(...) {}
// TODO: std::cout << "Передоз пакетами, сокет закрыт" << std::endl;
}
@@ -175,14 +177,14 @@ coro<> AsyncSocket::runSender(std::shared_ptr<AsyncContext> context) {
while(!SendPackets.SmartBuffer.empty()) {
SmartPacket &packet = SendPackets.SmartBuffer.front();
if(SendSize+packet.size() >= SendBuffer.size())
break;
if(packet.IsStillRelevant && !packet.IsStillRelevant()) {
if(packet.IsStillRelevant && !packet.IsStillRelevant (/* */)) {
SendPackets.SmartBuffer.pop_front();
continue;
}
if(SendSize+packet.size() >= SendBuffer.size())
break;
size_t packetSize = packet.size();
for(const auto &page : packet.getPages()) {
size_t needCopy = std::min<size_t>(packetSize, NetPool::PageSize);