Sorry for the lack of details, but I actually need to synchronize the qHttp usage, since it is called from a service class.
Let me try to explain in code:
1. An application calls
QDSServiceInfo service("getAllUsers", "BackendCommunication");
QDSAction* qdsAction = new QDSAction(service);
qdsAction->invoke();
QDSServiceInfo service("getAllUsers", "BackendCommunication");
QDSAction* qdsAction = new QDSAction(service);
qdsAction->invoke();
To copy to clipboard, switch view to plain text mode
2. In the BackendCommunication class, I do something like this:
// wait until request is done
while (responses[http] == "") {
}
QString response
= responses
[http
];
http->request(header, QByteArray().append(msg));
// wait until request is done
while (responses[http] == "") {
QCoreApplication::processEvents();
}
QString response = responses[http];
To copy to clipboard, switch view to plain text mode
That is why I used processEvents - the busy loop up there. My doubt was why it is preventing the application to quit, if the application eventually exits the method. I can successfully respond the response to the calling application.
Regarding that service lifecycle, is there something to do to avoid instancing every time? I need to have the BackendCommunication instance running as soon as possible (since it should be able to do some things without user input)
Bookmarks