mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-01-02 23:47:07 -05:00
remove clock feature
This commit is contained in:
parent
95be224caf
commit
2789798390
59
clock.go
59
clock.go
@ -1,59 +0,0 @@
|
||||
package core
|
||||
|
||||
import (
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Clock is a V2Ray feature that returns current time.
|
||||
type Clock interface {
|
||||
Feature
|
||||
|
||||
// Now returns current time.
|
||||
Now() time.Time
|
||||
}
|
||||
|
||||
type syncClock struct {
|
||||
sync.RWMutex
|
||||
Clock
|
||||
}
|
||||
|
||||
func (c *syncClock) Now() time.Time {
|
||||
c.RLock()
|
||||
defer c.RUnlock()
|
||||
|
||||
if c.Clock == nil {
|
||||
return time.Now()
|
||||
}
|
||||
|
||||
return c.Clock.Now()
|
||||
}
|
||||
|
||||
func (c *syncClock) Start() error {
|
||||
c.RLock()
|
||||
defer c.RUnlock()
|
||||
|
||||
if c.Clock == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return c.Clock.Start()
|
||||
}
|
||||
|
||||
func (c *syncClock) Close() error {
|
||||
c.RLock()
|
||||
defer c.RUnlock()
|
||||
|
||||
if c.Clock == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return c.Clock.Close()
|
||||
}
|
||||
|
||||
func (c *syncClock) Set(clock Clock) {
|
||||
c.Lock()
|
||||
defer c.Unlock()
|
||||
|
||||
c.Clock = clock
|
||||
}
|
8
v2ray.go
8
v2ray.go
@ -28,7 +28,6 @@ type Instance struct {
|
||||
router syncRouter
|
||||
ihm syncInboundHandlerManager
|
||||
ohm syncOutboundHandlerManager
|
||||
clock syncClock
|
||||
cmd syncCommander
|
||||
|
||||
access sync.Mutex
|
||||
@ -148,8 +147,6 @@ func (s *Instance) RegisterFeature(feature interface{}, instance Feature) error
|
||||
s.ihm.Set(instance.(InboundHandlerManager))
|
||||
case OutboundHandlerManager, *OutboundHandlerManager:
|
||||
s.ohm.Set(instance.(OutboundHandlerManager))
|
||||
case Clock, *Clock:
|
||||
s.clock.Set(instance.(Clock))
|
||||
case Commander, *Commander:
|
||||
s.cmd.Set(instance.(Commander))
|
||||
}
|
||||
@ -206,11 +203,6 @@ func (s *Instance) OutboundHandlerManager() OutboundHandlerManager {
|
||||
return &(s.ohm)
|
||||
}
|
||||
|
||||
// Clock returns the Clock used by this Instance. The returned Clock is always functional.
|
||||
func (s *Instance) Clock() Clock {
|
||||
return &(s.clock)
|
||||
}
|
||||
|
||||
// Commander returns the Commander used by this Instance. The returned Commander is always functional.
|
||||
func (s *Instance) Commander() Commander {
|
||||
return &(s.cmd)
|
||||
|
Loading…
Reference in New Issue
Block a user