Commit 8b0e100a authored by AlexStocks's avatar AlexStocks

Imp: delete time wheel

parent 3f195ce4
......@@ -14,11 +14,16 @@
## develop history ##
---
- 2019/06/07
> Improvement
* use time.After instead of wheel.After
* add remark for tcp reading
- 2018/10/16
> Feature
* add rpc/micro CallOneway/AsyncCall
* version: v1.0.3
- 2018/08/19
> Feature
* use multiple service config in service configuration
......@@ -32,7 +37,7 @@
- 2018/08/13
> Feature
* Add Micro
- 2018/08/07
> Improvement
* RPC package format: {2 Bytes Header len + Header + 2 Body len + Body} ---> {Header + Body}
......
......@@ -138,8 +138,7 @@ func (c *client) dialTCP() Session {
}
log.Infof("net.DialTimeout(addr:%s, timeout:%v) = error:%+v", c.addr, connectTimeout, err)
// time.Sleep(connInterval)
<-wheel.After(connInterval)
time.Sleep(connInterval)
}
}
......@@ -167,8 +166,7 @@ func (c *client) dialUDP() Session {
}
if err != nil {
log.Warnf("net.DialTimeout(addr:%s, timeout:%v) = error:%+v", c.addr, err)
// time.Sleep(connInterval)
<-wheel.After(connInterval)
time.Sleep(connInterval)
continue
}
......@@ -177,8 +175,7 @@ func (c *client) dialUDP() Session {
if length, err = conn.Write(connectPingPackage[:]); err != nil {
conn.Close()
log.Warnf("conn.Write(%s) = {length:%d, err:%+v}", string(connectPingPackage), length, err)
// time.Sleep(connInterval)
<-wheel.After(connInterval)
time.Sleep(connInterval)
continue
}
conn.SetReadDeadline(time.Now().Add(1e9))
......@@ -189,8 +186,7 @@ func (c *client) dialUDP() Session {
if err != nil {
log.Infof("conn{%#v}.Read() = {length:%d, err:%+v}", conn, length, err)
conn.Close()
// time.Sleep(connInterval)
<-wheel.After(connInterval)
time.Sleep(connInterval)
continue
}
//if err == nil {
......@@ -228,8 +224,7 @@ func (c *client) dialWS() Session {
}
log.Infof("websocket.dialer.Dial(addr:%s) = error:%+v", c.addr, err)
// time.Sleep(connInterval)
<-wheel.After(connInterval)
time.Sleep(connInterval)
}
}
......@@ -307,8 +302,7 @@ func (c *client) dialWSS() Session {
}
log.Infof("websocket.dialer.Dial(addr:%s) = error:%+v", c.addr, err)
// time.Sleep(connInterval)
<-wheel.After(connInterval)
time.Sleep(connInterval)
}
}
......
......@@ -233,8 +233,7 @@ func (s *server) runTcpEventLoop(newSession NewSessionCallback) {
return
}
if delay != 0 {
// time.Sleep(delay)
<-wheel.After(delay)
time.Sleep(delay)
}
client, err = s.accept(newSession)
if err != nil {
......
......@@ -41,14 +41,6 @@ const (
// session
/////////////////////////////////////////
var (
wheel = NewWheel(time.Millisecond*100, 1200) // wheel longest span is 2 minute
)
func GetTimeWheel() *Wheel {
return wheel
}
// getty base session
type session struct {
name string
......@@ -337,7 +329,7 @@ func (s *session) WritePkg(pkg interface{}, timeout time.Duration) error {
case s.wQ <- pkg:
break // for possible gen a new pkg
case <-wheel.After(timeout):
case <-time.After(timeout):
log.Warnf("%s, [session.WritePkg] wQ{len:%d, cap:%d}", s.Stat(), len(s.wQ), cap(s.wQ))
return ErrSessionBlocked
}
......@@ -510,7 +502,7 @@ LOOP:
log.Infof("[session.handleLoop] drop writeout package{%#v}", outPkg)
}
case <-wheel.After(s.period):
case <-time.After(s.period):
if flag {
if wsFlag {
err := wsConn.writePing()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment