2021-04-21 00:29:17 +08:00
|
|
|
package smux
|
|
|
|
|
2021-09-22 22:49:33 +08:00
|
|
|
func _itimediff(later, earlier uint32) int32 {
|
|
|
|
return (int32)(later - earlier)
|
|
|
|
}
|
|
|
|
|
2021-04-21 00:29:17 +08:00
|
|
|
type shaperHeap []writeRequest
|
|
|
|
|
|
|
|
func (h shaperHeap) Len() int { return len(h) }
|
2021-09-22 22:49:33 +08:00
|
|
|
func (h shaperHeap) Less(i, j int) bool { return _itimediff(h[j].prio, h[i].prio) > 0 }
|
2021-04-21 00:29:17 +08:00
|
|
|
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)) }
|
|
|
|
|
|
|
|
func (h *shaperHeap) Pop() interface{} {
|
|
|
|
old := *h
|
|
|
|
n := len(old)
|
|
|
|
x := old[n-1]
|
|
|
|
*h = old[0 : n-1]
|
|
|
|
return x
|
|
|
|
}
|