remove unused count variables

This commit is contained in:
Lunny Xiao 2017-09-26 12:54:13 +08:00
parent 14b6375dce
commit 3b19bd77f6
No known key found for this signature in database
GPG Key ID: C3B7C91B632F738A
2 changed files with 4 additions and 3 deletions

View File

@ -17,7 +17,7 @@ type EngineGroup struct {
policy GroupPolicy policy GroupPolicy
} }
func NewGroup(args1 interface{}, args2 interface{}, policies ...GroupPolicy) (*EngineGroup, error) { func NewEngineGroup(args1 interface{}, args2 interface{}, policies ...GroupPolicy) (*EngineGroup, error) {
var eg EngineGroup var eg EngineGroup
if len(policies) > 0 { if len(policies) > 0 {
eg.policy = policies[0] eg.policy = policies[0]

View File

@ -68,16 +68,17 @@ func NewRoundRobinPolicy() *RoundRobinPolicy {
} }
func (policy *RoundRobinPolicy) Slave(g *EngineGroup) *Engine { func (policy *RoundRobinPolicy) Slave(g *EngineGroup) *Engine {
var slaves = g.Slaves()
var pos int var pos int
policy.lock.Lock() policy.lock.Lock()
policy.pos++ policy.pos++
if policy.pos >= len(g.Slaves()) { if policy.pos >= len(slaves) {
policy.pos = 0 policy.pos = 0
} }
pos = policy.pos pos = policy.pos
policy.lock.Unlock() policy.lock.Unlock()
return g.Slaves()[pos] return slaves[pos]
} }
type WeightRoundRobinPolicy struct { type WeightRoundRobinPolicy struct {