XMLWordPrintable

    • Icon: Task Task
    • Resolution: Unresolved
    • Icon: Not Evaluated Not Evaluated
    • None
    • None
    • All Other Issues
    • None

      The current "standard" TaskTree usage pattern (e.g. https://codereview.qt-project.org/c/qt-creator/qt-creator/+/671707) looks like

      const auto onSetup = [input](Async<FormatOutput> &task) {
          task.setConcurrentCallData(format, input);
      };
      
      const auto onDone = [editor = QPointer<PlainTextEdit>(editor), input](constAsync<FormatOutput> &task, DoneWithresult) {
          if (result == DoneWith::Cancel)
              showError(Tr::tr("Filewasmodified."));
          else
              checkAndApplyTask(editor, input, task.result());
      };
      
      const auto onTreeSetup = [doc](TaskTree &taskTree) {
          QObject::connect(doc, &TextDocument::contentsChanged, &taskTree, &TaskTree::cancel);
      };
      
      GlobalTaskTree::start({AsyncTask<FormatOutput>(onSetup, onDone)}, onTreeSetup);

      which makes the onSetup/onDone lambdas and their actual use four lines below are "disconnected".

      I wonder whether it would be possible to have  a more "local" solution without losing the expressiveness of the 'onSetup' names, e.g something like

      AsyncTask<FormatOutput> format {
           setup = [input](Async<FormatOutput> &task) {
               task.setConcurrentCallData(format, input);
           },  
           done = [editor = QPointer<PlainTextEdit>(editor), input](const Async<FormatOutput> &task, DoneWith result) {
               if (result == DoneWith::Cancel)
                    showError(Tr::tr("File was modified."));
               else
                   checkAndApplyTask(editor, input, task.result());
           }   
      };
       
      GlobalTaskTree::start(
          group = { 
              format 
          },
          setup = [doc](TaskTree &taskTree) {
                  QObject::connect(doc, &TextDocument::contentsChanged, &taskTree, &TaskTree::cancel);
          }
      );

       

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            jkobus Jarek Kobus
            hjk hjk
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes