• Type: Icon: Sub-task Sub-task
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 8.0.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • None
    • Query Optimization
    • Fully Compatible
    • QE 2024-03-04, QE 2024-03-18

      Deferred is useful for "at-most-once" computation of expensive values.

      Currently, it wraps an std::function. Previously, the overhead of std::function in hot paths has been found to be significant.

      Deferred does not always require the type erasure of std::function.

      Therefore, refactor Deferred to allow storing arbitrary callables. This makes Deferred more flexible, while existing uses which do require type erasure can explicitly use Deferred<std::function<...>>.

      With this change, the following does not require an std::function

      auto deferredValue = Deferred([&](){
          // Do something expensive
          return thing;
      });
      ...
      
      void maybeUseExpensiveValue(auto func) {...}
      
      maybeUseExpensiveValue(deferredValue);
      maybeUseExpensiveValueSomewhereElse(deferredValue);
      

            Assignee:
            james.harrison@mongodb.com James Harrison
            Reporter:
            james.harrison@mongodb.com James Harrison
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: