after 2 weeks of porting over the ngc_ft1 code to solanaceae and rewriting the highlevel logic
(29 commits predate this)
This commit is contained in:
33
solanaceae/ngc_ft1/snd_buf.hpp
Normal file
33
solanaceae/ngc_ft1/snd_buf.hpp
Normal file
@@ -0,0 +1,33 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <cstdint>
|
||||
|
||||
struct SendSequenceBuffer {
|
||||
struct SSBEntry {
|
||||
std::vector<uint8_t> data; // the data (variable size, but smaller than 500)
|
||||
float time_since_activity {0.f};
|
||||
};
|
||||
|
||||
// sequence_id -> entry
|
||||
std::map<uint16_t, SSBEntry> entries;
|
||||
|
||||
uint16_t next_seq_id {0};
|
||||
|
||||
void erase(uint16_t seq);
|
||||
|
||||
// inflight chunks
|
||||
size_t size(void) const;
|
||||
|
||||
uint16_t add(std::vector<uint8_t>&& data);
|
||||
|
||||
template<typename FN>
|
||||
void for_each(float time_delta, FN&& fn) {
|
||||
for (auto& [id, entry] : entries) {
|
||||
entry.time_since_activity += time_delta;
|
||||
fn(id, entry.data, entry.time_since_activity);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
Reference in New Issue
Block a user