remeber the first sending transfer that could not send any packets and start there next iterate

This commit is contained in:
Green Sky 2023-09-01 23:20:03 +02:00
parent ba8befbb2d
commit 070585ab3d
No known key found for this signature in database
2 changed files with 12 additions and 2 deletions

View File

@ -286,10 +286,19 @@ void NGCFT1::iteratePeer(float time_delta, uint32_t group_number, uint32_t peer_
auto timeouts = peer.cca->getTimeouts();
std::set<CCAI::SeqIDType> timeouts_set{timeouts.cbegin(), timeouts.cend()};
for (size_t idx = 0; idx < peer.send_transfers.size(); idx++) {
if (peer.send_transfers.at(idx).has_value()) {
int64_t can_packet_size {peer.cca->canSend()}; // might get more space while iterating (time)
// change iterat start position to not starve transfers in the back
size_t iterated_count = 0;
bool last_send_found = false;
for (size_t idx = peer.next_send_transfer_send_idx; iterated_count < peer.send_transfers.size(); idx++, iterated_count++) {
idx = idx % peer.send_transfers.size();
if (peer.send_transfers.at(idx).has_value()) {
if (!last_send_found && can_packet_size <= 0) {
peer.next_send_transfer_send_idx = idx;
last_send_found = true; // only set once
}
updateSendTransfer(time_delta, group_number, peer_number, peer, idx, timeouts_set, can_packet_size);
}
}

View File

@ -188,6 +188,7 @@ class NGCFT1 : public ToxEventI, public NGCEXTEventI, public NGCFT1EventProvider
};
std::array<std::optional<SendTransfer>, 256> send_transfers;
size_t next_send_transfer_idx {0}; // next id will be 0
size_t next_send_transfer_send_idx {0};
};
std::map<uint32_t, Peer> peers;
};