Commit f066226b authored by alexstocks's avatar alexstocks

add empty

parent fce00ab9
...@@ -25,8 +25,6 @@ const ( ...@@ -25,8 +25,6 @@ const (
maxTimes = 10 maxTimes = 10
) )
type empty struct{}
type Client struct { type Client struct {
// net // net
sync.Mutex sync.Mutex
...@@ -37,7 +35,7 @@ type Client struct { ...@@ -37,7 +35,7 @@ type Client struct {
sessionMap map[*Session]empty sessionMap map[*Session]empty
sync.Once sync.Once
done chan struct{} done chan empty
wg sync.WaitGroup wg sync.WaitGroup
} }
...@@ -58,7 +56,7 @@ func NewClient(connNum int, connInterval time.Duration, serverAddr string) *Clie ...@@ -58,7 +56,7 @@ func NewClient(connNum int, connInterval time.Duration, serverAddr string) *Clie
interval: connInterval, interval: connInterval,
addr: serverAddr, addr: serverAddr,
sessionMap: make(map[*Session]empty, connNum), sessionMap: make(map[*Session]empty, connNum),
done: make(chan struct{}), done: make(chan empty),
} }
} }
......
...@@ -11,6 +11,11 @@ ...@@ -11,6 +11,11 @@
## develop history ## ## develop history ##
--- ---
- 2016/09/19
> 1 move empty to empty from client.go to session.go
>
> 2 version: 0.3.09
- 2016/09/12 - 2016/09/12
> 1 add defeat self connection logic in client.go & server.go > 1 add defeat self connection logic in client.go & server.go
> >
......
...@@ -30,12 +30,12 @@ type Server struct { ...@@ -30,12 +30,12 @@ type Server struct {
listener net.Listener listener net.Listener
sync.Once sync.Once
done chan struct{} done chan empty
wg sync.WaitGroup wg sync.WaitGroup
} }
func NewServer() *Server { func NewServer() *Server {
return &Server{done: make(chan struct{})} return &Server{done: make(chan empty)}
} }
func (this *Server) stop() { func (this *Server) stop() {
......
...@@ -20,8 +20,9 @@ import ( ...@@ -20,8 +20,9 @@ import (
) )
import ( import (
log "github.com/AlexStocks/log4go"
"runtime" "runtime"
log "github.com/AlexStocks/log4go"
) )
const ( const (
...@@ -105,6 +106,8 @@ var ( ...@@ -105,6 +106,8 @@ var (
ErrSessionBlocked = errors.New("Session full blocked") ErrSessionBlocked = errors.New("Session full blocked")
) )
type empty struct{}
// getty base session // getty base session
type Session struct { type Session struct {
name string name string
...@@ -113,7 +116,7 @@ type Session struct { ...@@ -113,7 +116,7 @@ type Session struct {
pkgHandler ReadWriter pkgHandler ReadWriter
listener EventListener listener EventListener
once sync.Once once sync.Once
done chan struct{} done chan empty
// readerDone chan struct{} // end reader // readerDone chan struct{} // end reader
peroid time.Duration peroid time.Duration
...@@ -134,7 +137,7 @@ func NewSession(conn net.Conn) *Session { ...@@ -134,7 +137,7 @@ func NewSession(conn net.Conn) *Session {
return &Session{ return &Session{
name: defaultSessionName, name: defaultSessionName,
gettyConn: newGettyConn(conn), gettyConn: newGettyConn(conn),
done: make(chan struct{}), done: make(chan empty),
// readerDone: make(chan struct{}), // readerDone: make(chan struct{}),
peroid: peroid, peroid: peroid,
rDeadline: netIOTimeout, rDeadline: netIOTimeout,
...@@ -146,7 +149,7 @@ func NewSession(conn net.Conn) *Session { ...@@ -146,7 +149,7 @@ func NewSession(conn net.Conn) *Session {
func (this *Session) Reset() { func (this *Session) Reset() {
this.name = defaultSessionName this.name = defaultSessionName
this.done = make(chan struct{}) this.done = make(chan empty)
// this.readerDone = make(chan struct{}) // this.readerDone = make(chan struct{})
this.peroid = peroid this.peroid = peroid
this.rDeadline = netIOTimeout this.rDeadline = netIOTimeout
......
...@@ -10,5 +10,5 @@ ...@@ -10,5 +10,5 @@
package getty package getty
var ( var (
Version = "0.3.08" Version = "0.3.09"
) )
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