24#include <seastar/net/packet.hh>
31template <
typename Offset,
typename Tag>
34 static uint64_t& linearizations_ref() {
35 static thread_local uint64_t linearization_count;
36 return linearization_count;
39 std::map<Offset, packet> map;
41 static uint64_t linearizations() {
42 return linearizations_ref();
45 void merge(Offset offset,
packet p) {
48 auto end = beg + p.len();
50 for (
auto it = map.begin(); it != map.end();) {
51 auto& seg_pkt = it->second;
52 auto seg_beg = it->first;
53 auto seg_end = seg_beg + seg_pkt.len();
55 if (seg_beg <= beg && end <= seg_end) {
59 }
else if (beg <= seg_beg && seg_end <= end) {
66 }
else if (beg < seg_beg && seg_beg <= end && end <= seg_end) {
69 auto trim = end - seg_beg;
70 seg_pkt.trim_front(trim);
71 p.append(std::move(seg_pkt));
76 }
else if (seg_beg <= beg && beg <= seg_end && seg_end < end) {
79 auto trim = seg_end - beg;
82 seg_pkt.append(std::move(p));
84 ++linearizations_ref();
99 ++linearizations_ref();
100 map.emplace(beg, std::move(p));
106 for (
auto it = map.begin(); it != map.end();) {
108 auto& seg_pkt = it->second;
109 auto seg_beg = it->first;
110 auto seg_end = seg_beg + seg_pkt.len();
115 if (it_next == map.end()) {
118 auto& p = it_next->second;
119 auto beg = it_next->first;
120 auto end = beg + p.len();
123 if (seg_beg <= beg && beg <= seg_end && seg_end < end) {
125 auto trim = seg_end - beg;
128 seg_pkt.append(std::move(p));
136 }
else if (end <= seg_end) {
141 }
else if (seg_end < beg) {
Definition: packet-util.hh:32
Seastar API namespace.
Definition: abort_on_ebadf.hh:26