Replace Timeout API with lambdas

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Done
    • Priority: Unknown
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Java Drivers
    • Not Needed
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?
    • None
    • None
    • None
    • None
    • None
    • None

      It is too easy to encounter a race with the current methods, or to supply an incorrect infinite timeout value (0, -1) when calling an external method. This proposes to replace the existing Timeout non-static methods with a single "run" method. Usage example:

              return timeout.run(MILLISECONDS, (ms) ->

      {             collection.setTimeout(ms, MS);         }

      , () ->

      { // infinite:             collection.setTimeout(MS);         }

      , () ->

      {             throw new MongoOperationTimeoutException(DEFAULT_TIMEOUT_MESSAGE);         }

      );

       

      This should also remove TimePoint#hasExpired calling elapsed twice.

              Assignee:
              Maxim Katcharov
              Reporter:
              Maxim Katcharov
              None
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: