summaryrefslogtreecommitdiffstats
path: root/common/clientapi.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2016-02-08 18:44:31 +0100
committerChristian Mollekopf <chrigi_1@fastmail.fm>2016-02-08 18:44:31 +0100
commit65be895825a61ae463d09604634b064570febdc2 (patch)
tree790ceda8e9372405a0473a0534128ad24198b1fb /common/clientapi.cpp
parentb8200434209c317ebc4883b9f87513991bae33e3 (diff)
downloadsink-65be895825a61ae463d09604634b064570febdc2.tar.gz
sink-65be895825a61ae463d09604634b064570febdc2.zip
Trace some timings.
Diffstat (limited to 'common/clientapi.cpp')
-rw-r--r--common/clientapi.cpp22
1 files changed, 15 insertions, 7 deletions
diff --git a/common/clientapi.cpp b/common/clientapi.cpp
index a13456b..413abd3 100644
--- a/common/clientapi.cpp
+++ b/common/clientapi.cpp
@@ -22,6 +22,7 @@
22 22
23#include <QtConcurrent/QtConcurrentRun> 23#include <QtConcurrent/QtConcurrentRun>
24#include <QTimer> 24#include <QTimer>
25#include <QTime>
25#include <QEventLoop> 26#include <QEventLoop>
26#include <QAbstractItemModel> 27#include <QAbstractItemModel>
27#include <QDir> 28#include <QDir>
@@ -162,13 +163,15 @@ KAsync::Job<void> Store::remove(const DomainType &domainObject)
162KAsync::Job<void> Store::shutdown(const QByteArray &identifier) 163KAsync::Job<void> Store::shutdown(const QByteArray &identifier)
163{ 164{
164 Trace() << "shutdown " << identifier; 165 Trace() << "shutdown " << identifier;
165 return ResourceAccess::connectToServer(identifier).then<void, QSharedPointer<QLocalSocket>>([identifier](QSharedPointer<QLocalSocket> socket, KAsync::Future<void> &future) { 166 auto time = QSharedPointer<QTime>::create();
167 time->start();
168 return ResourceAccess::connectToServer(identifier).then<void, QSharedPointer<QLocalSocket>>([identifier, time](QSharedPointer<QLocalSocket> socket, KAsync::Future<void> &future) {
166 //We can't currently reuse the socket 169 //We can't currently reuse the socket
167 socket->close(); 170 socket->close();
168 auto resourceAccess = QSharedPointer<Sink::ResourceAccess>::create(identifier); 171 auto resourceAccess = QSharedPointer<Sink::ResourceAccess>::create(identifier);
169 resourceAccess->open(); 172 resourceAccess->open();
170 resourceAccess->sendCommand(Sink::Commands::ShutdownCommand).then<void>([&future, resourceAccess]() { 173 resourceAccess->sendCommand(Sink::Commands::ShutdownCommand).then<void>([&future, resourceAccess, time]() {
171 Trace() << "Shutdown complete"; 174 Trace() << "Shutdown complete." << Log::TraceTime(time->elapsed());
172 future.setFinished(); 175 future.setFinished();
173 }).exec(); 176 }).exec();
174 }, 177 },
@@ -183,10 +186,12 @@ KAsync::Job<void> Store::shutdown(const QByteArray &identifier)
183KAsync::Job<void> Store::start(const QByteArray &identifier) 186KAsync::Job<void> Store::start(const QByteArray &identifier)
184{ 187{
185 Trace() << "start " << identifier; 188 Trace() << "start " << identifier;
189 auto time = QSharedPointer<QTime>::create();
190 time->start();
186 auto resourceAccess = QSharedPointer<Sink::ResourceAccess>::create(identifier); 191 auto resourceAccess = QSharedPointer<Sink::ResourceAccess>::create(identifier);
187 resourceAccess->open(); 192 resourceAccess->open();
188 return resourceAccess->sendCommand(Sink::Commands::PingCommand).then<void>([resourceAccess]() { 193 return resourceAccess->sendCommand(Sink::Commands::PingCommand).then<void>([resourceAccess, time]() {
189 Trace() << "Start complete"; 194 Trace() << "Start complete." << Log::TraceTime(time->elapsed());
190 }); 195 });
191} 196}
192 197
@@ -303,15 +308,18 @@ KAsync::Job<void> Resources::inspect(const Inspection &inspectionCommand)
303{ 308{
304 auto resource = inspectionCommand.resourceIdentifier; 309 auto resource = inspectionCommand.resourceIdentifier;
305 310
311 auto time = QSharedPointer<QTime>::create();
312 time->start();
306 Trace() << "Sending inspection " << resource; 313 Trace() << "Sending inspection " << resource;
307 auto resourceAccess = QSharedPointer<Sink::ResourceAccess>::create(resource); 314 auto resourceAccess = QSharedPointer<Sink::ResourceAccess>::create(resource);
308 resourceAccess->open(); 315 resourceAccess->open();
309 auto notifier = QSharedPointer<Sink::Notifier>::create(resourceAccess); 316 auto notifier = QSharedPointer<Sink::Notifier>::create(resourceAccess);
310 auto id = QUuid::createUuid().toByteArray(); 317 auto id = QUuid::createUuid().toByteArray();
311 return resourceAccess->sendInspectionCommand(id, ApplicationDomain::getTypeName<DomainType>(), inspectionCommand.entityIdentifier, inspectionCommand.property, inspectionCommand.expectedValue) 318 return resourceAccess->sendInspectionCommand(id, ApplicationDomain::getTypeName<DomainType>(), inspectionCommand.entityIdentifier, inspectionCommand.property, inspectionCommand.expectedValue)
312 .template then<void>([resourceAccess, notifier, id](KAsync::Future<void> &future) { 319 .template then<void>([resourceAccess, notifier, id, time](KAsync::Future<void> &future) {
313 notifier->registerHandler([&future, id](const Notification &notification) { 320 notifier->registerHandler([&future, id, time](const Notification &notification) {
314 if (notification.id == id) { 321 if (notification.id == id) {
322 Trace() << "Inspection complete." << Log::TraceTime(time->elapsed());
315 if (notification.code) { 323 if (notification.code) {
316 future.setError(-1, "Inspection returned an error: " + notification.message); 324 future.setError(-1, "Inspection returned an error: " + notification.message);
317 } else { 325 } else {