@@ -4378,7 +4378,20 @@ func (iter *Iter) Next(result interface{}) bool {
43784378 return iter .NextWithTimeout (result , iter .timeout )
43794379}
43804380
4381+ func (iter * Iter ) NextWithTrace (result interface {}, trace func (string , int , func ())) bool {
4382+ return iter .NextWithTimeoutAndTrace (result , iter .timeout , trace )
4383+ }
4384+
43814385func (iter * Iter ) NextWithTimeout (result interface {}, timeout time.Duration ) bool {
4386+ return iter .NextWithTimeoutAndTrace (result , timeout , nil )
4387+ }
4388+
4389+ func (iter * Iter ) NextWithTimeoutAndTrace (result interface {}, timeout time.Duration , trace func (string , int , func ())) bool {
4390+ getMore := iter .getMore
4391+ if trace != nil {
4392+ getMore = func () { trace (iter .op .collection , int (iter .op .limit ), iter .getMore ) }
4393+ }
4394+
43824395 iter .m .Lock ()
43834396 iter .timedout = false
43844397 deadline := time.Time {}
@@ -4398,7 +4411,7 @@ func (iter *Iter) NextWithTimeout(result interface{}, timeout time.Duration) boo
43984411 // If we have yet to receive data, increment the timer until we timeout.
43994412 if iter .docsToReceive == 0 {
44004413 // run a getmore to fetch more data.
4401- iter . getMore ()
4414+ getMore ()
44024415 if iter .err != nil {
44034416 break
44044417 }
@@ -4449,7 +4462,7 @@ func (iter *Iter) NextWithTimeout(result interface{}, timeout time.Duration) boo
44494462 // we still have a live cursor and currently expect data.
44504463 iter .docsBeforeMore --
44514464 if iter .docsBeforeMore == - 1 {
4452- iter . getMore ()
4465+ getMore ()
44534466 }
44544467 }
44554468 iter .m .Unlock ()
0 commit comments