mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-04-29 16:58:34 +00:00
v1.0.0
This commit is contained in:
parent
47d23e9972
commit
c7f7c08ead
711 changed files with 82154 additions and 2 deletions
30
common/peer/latency.go
Normal file
30
common/peer/latency.go
Normal file
|
@ -0,0 +1,30 @@
|
|||
package peer
|
||||
|
||||
import (
|
||||
"sync"
|
||||
)
|
||||
|
||||
type Latency interface {
|
||||
Value() uint64
|
||||
}
|
||||
|
||||
type HasLatency interface {
|
||||
ConnectionLatency() Latency
|
||||
HandshakeLatency() Latency
|
||||
}
|
||||
|
||||
type AverageLatency struct {
|
||||
access sync.Mutex
|
||||
value uint64
|
||||
}
|
||||
|
||||
func (al *AverageLatency) Update(newValue uint64) {
|
||||
al.access.Lock()
|
||||
defer al.access.Unlock()
|
||||
|
||||
al.value = (al.value + newValue*2) / 3
|
||||
}
|
||||
|
||||
func (al *AverageLatency) Value() uint64 {
|
||||
return al.value
|
||||
}
|
1
common/peer/peer.go
Normal file
1
common/peer/peer.go
Normal file
|
@ -0,0 +1 @@
|
|||
package peer
|
Loading…
Add table
Add a link
Reference in a new issue