mirror of
https://github.com/nadoo/glider.git
synced 2025-02-23 01:15:41 +08:00
27 lines
594 B
Go
27 lines
594 B
Go
package smux
|
|
|
|
func _itimediff(later, earlier uint32) int32 {
|
|
return (int32)(later - earlier)
|
|
}
|
|
|
|
type shaperHeap []writeRequest
|
|
|
|
func (h shaperHeap) Len() int { return len(h) }
|
|
func (h shaperHeap) Less(i, j int) bool {
|
|
if h[i].class != h[j].class {
|
|
return h[i].class < h[j].class
|
|
}
|
|
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)) }
|
|
|
|
func (h *shaperHeap) Pop() interface{} {
|
|
old := *h
|
|
n := len(old)
|
|
x := old[n-1]
|
|
*h = old[0 : n-1]
|
|
return x
|
|
}
|