implementato bulk insert con _id generato

This commit is contained in:
Michele 2016-11-03 17:42:37 +01:00
parent c2a5e09323
commit d7d68f4bf4
8 changed files with 71 additions and 85 deletions

View file

@ -15,7 +15,7 @@ type Counter struct {
err int
dup int
time time.Duration
wg []int
wg int
}
// NewCounter iniitialized Counter structure
@ -27,7 +27,7 @@ func NewCounter() *Counter {
rem: 0,
dup: 0,
time: 0,
wg: make([]int, opts.Concurrent),
wg: 0,
}
}
@ -60,10 +60,10 @@ func (c *Counter) AddRem(add int) {
}
// AddWG ...
func (c *Counter) AddWG(id int) {
func (c *Counter) AddWG() {
c.mu.Lock()
defer c.mu.Unlock()
c.wg[id]++
c.wg++
}
// AddErr ...
@ -74,10 +74,10 @@ func (c *Counter) AddErr() {
}
// DelWG ...
func (c *Counter) DelWG(id int) {
func (c *Counter) DelWG() {
c.mu.Lock()
defer c.mu.Unlock()
c.wg[id]--
c.wg--
}
// GetUser return total users
@ -121,10 +121,10 @@ func (c *Counter) GetRem() (ret int) {
}
// GetWG ...
func (c *Counter) GetWG(id int) (ret int) {
func (c *Counter) GetWG() (ret int) {
c.mu.Lock()
defer c.mu.Unlock()
ret = c.wg[id]
ret = c.wg
return
}