mirror of
https://github.com/soypat/lneto.git
synced 2026-08-20 22:49:11 +00:00
rephrase tcp.Value methods; add Ring.FreeLimited; work on TxQueue
This commit is contained in:
+6
-6
@@ -24,24 +24,24 @@ type Value uint32
|
||||
type Size uint32
|
||||
|
||||
// LessThan checks if v is before w (modulo 32) i.e., v < w.
|
||||
func LessThan(v, w Value) bool {
|
||||
func (v Value) LessThan(w Value) bool {
|
||||
return int32(v-w) < 0
|
||||
}
|
||||
|
||||
// LessThanEq returns true if v==w or v is before (modulo 32) i.e., v < w.
|
||||
func LessThanEq(v, w Value) bool {
|
||||
return v == w || LessThan(v, w)
|
||||
func (v Value) LessThanEq(w Value) bool {
|
||||
return v == w || v.LessThan(w)
|
||||
}
|
||||
|
||||
// InRange checks if v is in the range [a,b) (modulo 32), i.e., a <= v < b.
|
||||
func InRange(v, a, b Value) bool {
|
||||
func (v Value) InRange(a, b Value) bool {
|
||||
return v-a < b-a
|
||||
}
|
||||
|
||||
// InWindow checks if v is in the window that starts at 'first' and spans 'size'
|
||||
// sequence numbers (modulo 32).
|
||||
func InWindow(v, first Value, size Size) bool {
|
||||
return InRange(v, first, Add(first, size))
|
||||
func (v Value) InWindow(first Value, size Size) bool {
|
||||
return v.InRange(first, Add(first, size))
|
||||
}
|
||||
|
||||
// Add calculates the sequence number following the [v, v+s) window.
|
||||
|
||||
Reference in New Issue
Block a user