Introduce API for tailable cursors that doesn't break Iterator contract

XMLWordPrintableJSON

    • Type: New Feature
    • Resolution: Done
    • Priority: Major - P3
    • 3.0.0
    • Affects Version/s: None
    • Component/s: Query Operations
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Current proposal is something like this:

      public interface TailableCursor<T> extends MongoCursor<T> {
          /** 
              Move to the next document if available, otherwise return null.
          */
          T tryNext();
      }
      

      Normal usage would just use the existing MongoCursor interface (which extends Iterator and adds a close() method), but for users that don't want to block waiting for the next document, the non-blocking tryNext() method can be used, e.g.

          while (true) {
               Document doc = cursor.tryNext();
               // do other useful work here
          }
      

              Assignee:
              Ross Lawley
              Reporter:
              Jeffrey Yemin
              None
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: