Skip to content

Commit

Permalink
ignore prio settinn in writeFrameInternal
Browse files Browse the repository at this point in the history
  • Loading branch information
xtaci committed Feb 7, 2023
1 parent 5bfb5a9 commit d5ca637
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
10 changes: 2 additions & 8 deletions shaper.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,8 @@ func _itimediff(later, earlier uint32) int32 {

type shaperHeap []writeRequest

func (h shaperHeap) Len() int { return len(h) }
func (h shaperHeap) Less(i, j int) bool {
if h[i].frame.sid == h[j].frame.sid {
return _itimediff(h[j].seq, h[i].seq) > 0
} else {
return _itimediff(h[j].prio, h[i].prio) > 0
}
}
func (h shaperHeap) Len() int { return len(h) }
func (h shaperHeap) Less(i, j int) bool { return _itimediff(h[j].seq, h[i].seq) > 0 }
func (h shaperHeap) Swap(i, j int) { h[i], h[j] = h[j], h[i] }
func (h *shaperHeap) Push(x interface{}) { *h = append(*h, x.(writeRequest)) }

Expand Down
22 changes: 22 additions & 0 deletions shaper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,25 @@ func TestShaper(t *testing.T) {
lastPrio = w.prio
}
}

func TestShaper2(t *testing.T) {
w1 := writeRequest{prio: 10, seq: 1} // stream 0
w2 := writeRequest{prio: 10, seq: 2}
w3 := writeRequest{prio: 20, seq: 3}
w4 := writeRequest{prio: 100, seq: 4}
w5 := writeRequest{prio: (1 << 32) - 1, seq: 5}
w6 := writeRequest{prio: 10, seq: 1, frame: Frame{sid: 10}} // stream 1

var reqs shaperHeap
heap.Push(&reqs, w6)
heap.Push(&reqs, w5)
heap.Push(&reqs, w4)
heap.Push(&reqs, w3)
heap.Push(&reqs, w2)
heap.Push(&reqs, w1)

for len(reqs) > 0 {
w := heap.Pop(&reqs).(writeRequest)
t.Log("prio:", w.prio, "sid:", w.frame.sid, "seq:", w.seq)
}
}

0 comments on commit d5ca637

Please sign in to comment.