@@ -18,14 +18,14 @@ type Operation struct {
1818 Count atomic.Int64 // number of bytes seen
1919 avail atomic.Int64
2020 count atomic.Int64
21- ch <- chan int
21+ ch <- chan int64
2222 reader bool
2323 mu sync.Mutex // protects following
2424 stopCh chan struct {}
2525}
2626
2727func NewOperation (t * Ticker , limits []int64 , idx int ) (op * Operation ) {
28- ch := make (chan int )
28+ ch := make (chan int64 )
2929 op = & Operation {
3030 Ticker : t ,
3131 ch : ch ,
@@ -54,7 +54,7 @@ func (op *Operation) Stop() {
5454 }
5555}
5656
57- func (op * Operation ) run (ch chan <- int ) {
57+ func (op * Operation ) run (ch chan <- int64 ) {
5858 defer close (ch )
5959
6060 op .mu .Lock ()
@@ -65,12 +65,12 @@ func (op *Operation) run(ch chan<- int) {
6565
6666 if stopCh != nil {
6767 for {
68- var limitCh chan <- int
69- var todo int
70- var batch int
68+ var limitCh chan <- int64
69+ var todo int64
70+ var batch int64
7171 if limit := op .Limit .Load (); limit > 0 {
7272 limitCh = ch
73- todo = max (1 , int ( limit / secparts ) )
73+ todo = max (1 , limit / secparts )
7474 batch = min (batchsize , todo )
7575 }
7676 waitCh := op .WaitCh ()
@@ -82,7 +82,7 @@ func (op *Operation) run(ch chan<- int) {
8282 return
8383 case limitCh <- batch :
8484 todo -= batch
85- todo += int ( op .avail .Swap (0 ) )
85+ todo += op .avail .Swap (0 )
8686 if todo < batch {
8787 <- waitCh
8888 break partialsecond
@@ -119,15 +119,15 @@ func (op *Operation) io(fn func([]byte) (int, error), b []byte) (n int, err erro
119119 err = io .EOF
120120 if ok {
121121 var done int
122- todo := min (len (b ), batch )
122+ todo := min (int64 ( len (b ) ), batch )
123123 done , err = fn (b [:todo ])
124- op .avail .Add (int64 ( batch - done ))
124+ op .avail .Add (batch - int64 ( done ))
125125 if done > 0 {
126126 op .count .Add (int64 (done ))
127- n += done
127+ n += int ( done )
128128 b = b [done :]
129129 }
130- if op .reader && done < todo {
130+ if op .reader && int64 ( done ) < todo {
131131 break
132132 }
133133 }
0 commit comments