-
Notifications
You must be signed in to change notification settings - Fork 828
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Design question: how to handle long computations in a node? #452
Comments
Hello, I never tried to work-around similar cases. #include <QCoreApplication>
#include <QtConcurrent>
#include <QFuture>
#include <QFutureWatcher>
#include <QDebug>
void longTask() {
qDebug() << "Task started on thread:" << QThread::currentThread();
QThread::sleep(5); // Simulate long-lasting task
}
int main(int argc, char *argv[]) {
QCoreApplication app(argc, argv);
QFuture<void> future = QtConcurrent::run(longTask);
QFutureWatcher<void> watcher;
QObject::connect(&watcher, &QFutureWatcher<void>::finished, [&]() {
qDebug() << "Task completed on thread:" << QThread::currentThread();
app.quit();
});
watcher.setFuture(future);
return app.exec();
} Isn't it what you did before? Thanks |
Yes this is more or less the solution I came with with version 2, but I was struggling to decide what to do with input data that was coming when a task is executed.
It becomes even more complex when these nodes have multiple inputs (A,B,C), so each update of each input triggers a new computation that is actually not the one you expect, but that could be a valid one to compute in theory. This can become a big bottleneck as just to load an initial .flow tree, some nodes are updated 16 times in some scenarios I have for example. I was wondering if there was some best practice that I might have missed that you might know. Thanks for the heavy work on this project :) |
Hello, I'm trying to see what efforts would be needed to port to V3 and look at the changes I've done in the core logic so far: I was wondering what would be the best strategy to handle long computations? Right now the UI hangs if anything takes a long time to compute in a node.
Example: just add a Sleep of 10 seconds in one of the compute() function in the calculator example to see what I'm experiencing.
In my previous implementation I created WorkerNodeDataModels and workers but I'm not sure it's the best strategy (what happens when you have multiple inputs, what do you do with current long computation, etc etc...) and was wondering if this is something you thought about?
The text was updated successfully, but these errors were encountered: